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