Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么wrong answer?#include<stdio.h> #include<math.h> void main(){ int i,n,sum,sum1=0; for(;;){ scanf("%d",&n); if(n==0) break; sum=0; for(i=1;i<n;i++){ sum=sum+i*i; if(n==(i*i+i)/2){ sum1=sum; } else if(n>(i*i-i)/2&&n<=(i*i+i)/2){ sum1=sum-((i*i+i)/2-n)*i; } } printf("%d %d\n",n,sum1); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator