wrong: #include"stdio.h" __int64 a[100002],i; int main() { int n; a[1]=1; a[2]=3; for(i=3;i<100002;i++) { if(i%3==0) a[i]=a[i-1]+i*i*i; else a[i]=a[i-1]+i; } while(scanf("%d",&n)!=EOF&&n>0)//这里n>=0,!!!!一定要注意!! printf("%I64d\n",a[n]); return 0; } AC: #include"stdio.h" __int64 a[100005],i; int main( ) { int n; for(i=1;i<=100000;i++) { if(i%3==0) a[i]=a[i-1]+i*i*i; else a[i]=a[i-1]+i; } while(scanf("%d",&n)&&n>=0) { printf("%I64d\n",a[n]); } return 0; }