|   | 
			  標題:連續奇數和
 
 小明看到一本書上寫著:任何數字的立方都可以表示為連續奇數的和。
 
 比如:
 
 2^3 = 8 = 3 + 5
 3^3 = 27 = 7 + 9 + 11
 4^3 = 64 = 1 + 3 + ... + 15
 
 雖然他沒有想出怎麼證明,但他想通過計算機進行驗證。
 
 請你幫助小明寫出 111 的立方之連續奇數和表示法的起始數字。如果有多個表示方案,選擇起始數字小的方案。
 
 請嚴格按照要求,通過瀏覽器提交答案。
 注意:只提交一個整數,不要寫其它附加內容,比如:說明性的文字。
 
 
 
 | 
                
          |   | 
			  【代碼】#include <stdio.h>
 #include <conio.h>
 
 #define f2013_2 main
 
 #define NUM 1367631
 #define SUM ((start + end) * (end - start + 2) / 4)
 
 int f2013_2(void)
 {
 int start, end;
 int sum;
 for (start = 1; start <= NUM; start += 2)
 {
 for (end = start + 2; (sum = SUM) <= NUM; end += 2)
 {
 printf("%d + ... + %d = %d", start, end, sum);
 if (sum == NUM)
 {
 puts("\nFound!");
 _getch();
 }
 else
 putchar('\n');
 }
 }
 return 0;
 }
 
 | 
                
          |   | 
			  【代碼2】#include <stdio.h>
 #include <conio.h>
 
 #define f2013_2 main
 
 #define NUM 1367631
 #define SUM ((start + end) * (end - start + 2) / 4)
 
 int f2013_2(void)
 {
 int start, end;
 int sum;
 for (start = 1; start <= NUM; start += 2)
 {
 for (end = start + 2; (sum = SUM) <= NUM; end += 2)
 {
 if (sum == NUM)
 printf("%d + ... + %d = %d\n", start, end, sum);
 }
 }
 return 0;
 }
 
 | 
                
          |   | 
			  【找到的算式】371 + ... + 2367 = 1367631
 3775 + ... + 4439 = 1367631
 12211 + ... + 12431 = 1367631
 36927 + ... + 36999 = 1367631
 50627 + ... + 50679 = 1367631
 151951 + ... + 151967 = 1367631
 455875 + ... + 455879 = 1367631
 Press any key to continue . . .
 
 |