题解 | #尼科彻斯定理#
尼科彻斯定理
http://www.nowcoder.com/practice/dbace3a5b3c4480e86ee3277f3fe1e85
#include<stdio.h>
int main() { int m = 0;
while (scanf("%d", &m) != EOF)
{
int tri = m * m * m;//n立方
int i = 0;
for (i = 1; i < 1000000; i += 2)
{
int sum = 0;//和
int j = 0;
int tmp = i;
for (j = 0; j < m; j++)
{
sum += tmp;
tmp += 2;
}
tmp = i;
if (sum == tri)
{
for (j = 0; j < m-1; j++)
{
printf("%d+", tmp);
tmp += 2;
}
printf("%d\n", tmp);
}
}
}
return 0;
}