找回密码
 欢迎注册
查看: 10442|回复: 5

[讨论] 立方数数字和问题

[复制链接]
发表于 2011-9-12 19:41:50 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?欢迎注册

×
沿袭平方数数字和问题的描述 http://bbs.emath.ac.cn/thread-642-1-1.html 考虑平方数 先给出递归公式 T(0) = 0 N(0) = 0 F(0) = 1 T(i+1)=T(i)+F(i) N(i+1)=N(i)+6 F(i+1)=F(i)+N(i) 则,T(0)...T(i)形成一系列的平方数
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2011-9-12 20:58:05 | 显示全部楼层
代码
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define M 6
  4. #define D6 1000000
  5. int D[D6];
  6. int T[M];
  7. int N[M];
  8. int F[M];
  9. int dT, dN, dF;
  10. int mask[480];
  11. void init(void)
  12. {
  13. int i, j, k, l, m, n;
  14. for (i = 0; i <= 9; i ++)
  15. for (j = 0; j <= 9; j ++)
  16. for (k = 0; k <= 9; k ++)
  17. for (l = 0; l <= 9; l ++)
  18. for (m = 0; m <= 9; m ++)
  19. for (n = 0; n <= 9; n ++)
  20. D[i*100000+j*10000+k*1000+l*100+m*10+n] = i + j + k + l + m + n;
  21. for (i = 0; i < M; i ++)
  22. T[i] = N[i] = F[i] = 0;
  23. F[0] = 1;
  24. dT = dN = dF = 1;
  25. for (i = 0; i < 480; i ++)
  26. mask[i] = 0;
  27. }
  28. void newT( void )
  29. {
  30. int i, t = 0;
  31. for (i = 0; i < dF; i ++)
  32. {
  33. t += T[i] + F[i];
  34. t >= D6 ? (T[i] = t - D6, t = 1) : (T[i] = t, t = 0);
  35. }
  36. i = dF;
  37. while ((t > 0) && (i < dT))
  38. {
  39. t += T[i];
  40. t >= D6 ? (T[i] = t - D6, t = 1) : (T[i] = t, t = 0);
  41. i ++;
  42. }
  43. if (t > 0)
  44. T[dT++] = 1;
  45. }
  46. void newN( void )
  47. {
  48. int i = 0, t = 6;
  49. while ((t > 0) && (i < dN))
  50. {
  51. t += N[i];
  52. t >= D6 ? (N[i] = t - D6, t = 1) : (N[i] = t, t = 0);
  53. i ++;
  54. }
  55. if (t > 0)
  56. N[dN ++] = 1;
  57. }
  58. void newF( void )
  59. {
  60. int i, t = 0;
  61. for (i = 0; i < dN; i ++)
  62. {
  63. t += F[i] + N[i];
  64. t >= D6 ? (F[i] = t - D6, t = 1) : (F[i] = t, t = 0);
  65. }
  66. i = dN;
  67. while ((t > 0) && (i < dF))
  68. {
  69. t += F[i];
  70. t >= D6 ? (F[i] = t - D6, t = 1) : (F[i] = t, t = 0);
  71. i ++;
  72. }
  73. if (t > 0)
  74. F[dF++] = 1;
  75. }
  76. void checkT( void )
  77. {
  78. int i, t = 0;
  79. for (i = 0; i < dT; i ++)
  80. t += D[T[i]];
  81. if (mask[t] == 0)
  82. {
  83. printf("Find %d: ", t);
  84. i = dT - 1;
  85. printf("%d", T[i--]);
  86. while (i >= 0)
  87. printf("%06d", T[i--]);
  88. printf("\n");
  89. mask[t] = 1;
  90. }
  91. }
  92. void checkVar( int * v, int len)
  93. {
  94. if (len <= 0)
  95. return ;
  96. printf("%d", v[-- len]);
  97. while ( len > 0)
  98. printf("%06d", v[-- len]);
  99. printf("\n");
  100. }
  101. int main( void )
  102. {
  103. long long i = 0;
  104. init( );
  105. while ( i <= 100000000 )
  106. {
  107. //printf("%d: %d %d %d T, N, F====\n", i, dT, dN, dF);
  108. //checkVar(T, dT);
  109. //checkVar(N, dN);
  110. //checkVar(F, dF);
  111. newT( );
  112. newN( );
  113. newF( );
  114. checkT( );
  115. i ++;
  116. }
  117. }
复制代码
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2011-9-12 20:59:13 | 显示全部楼层
10^24内结果
  1. Find 1: 1
  2. Find 8: 8
  3. Find 9: 27
  4. Find 10: 64
  5. Find 18: 729
  6. Find 19: 2197
  7. Find 17: 2744
  8. Find 28: 6859
  9. Find 26: 17576
  10. Find 27: 19683
  11. Find 35: 148877
  12. Find 36: 287496
  13. Find 37: 438976
  14. Find 44: 778688
  15. Find 45: 2299968
  16. Find 46: 3869893
  17. Find 53: 43986977
  18. Find 54: 75686967
  19. Find 55: 174676879
  20. Find 62: 596947688
  21. Find 63: 796597983
  22. Find 64: 1693669888
  23. Find 73: 7598896696
  24. Find 71: 9649992689
  25. Find 72: 56888939736
  26. Find 80: 78898389569
  27. Find 81: 197747699976
  28. Find 82: 677298787768
  29. Find 89: 1778597976896
  30. Find 98: 1999899757799
  31. Find 90: 4329949978899
  32. Find 91: 6999657683689
  33. Find 100: 27969886988875
  34. Find 99: 68986579789197
  35. Find 107: 254996898985997
  36. Find 108: 299982589968888
  37. Find 109: 994878767299789
  38. Find 116: 2679768989786699
  39. Find 118: 9949889468976787
  40. Find 117: 18696769447799997
  41. Find 125: 39677989979796875
  42. Find 126: 129937879999769499
  43. Find 127: 188979889884278779
  44. Find 135: 849894379779889989
  45. Find 136: 968397868897889977
  46. Find 134: 1737876998969969768
  47. Find 144: 9688689596689799688
  48. Find 143: 19786889787799686488
  49. Find 145: 48879314999968898899
  50. Find 154: 67988999959868987875
  51. Find 153: 85897988298989489979
  52. Find 152: 179999887787788988375
  53. Find 162: 2979909779796589978989
  54. Find 161: 4479959888985687898688
  55. Find 163: 8783893698974994898999
  56. Find 170: 67899899689199886577697
  57. Find 171: 68885699985378975978999
  58. Find 172: 84997849968878977898776
  59. Find 179: 529967889999499896479969
  60. Find 181: 688859969398989879749896
复制代码
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2011-9-12 21:59:59 | 显示全部楼层
四次方递归公式 Q(0)=0 F(0)=1 N(0)=14 M(0)=36 Q(i+1)=Q(i)+F(i) F(i+1)=F(i)+N(i) N(i+1)=N(i)+M(i) M(i+1)=M(i)+24 Q(i)组成四次方序列
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2012-2-10 13:52:18 | 显示全部楼层
多谢分享!
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

小黑屋|手机版|数学研发网 ( 苏ICP备07505100号 )

GMT+8, 2024-11-21 21:26 , Processed in 0.030678 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表