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 |
大牛们帮忙看看,为什么老wa呢?#include<iostream.h> void main(){ int day; while(cin>>day){ int k,t; long int total=0; k=1; while((k*(k+1)/2)<day){ k++; } t=k*(k+1)/2; if(t>day){k=k-1;}; t=day-((k*(k+1))/2); int i; for(i=1;i<=k;i++){ int j; for(j=1;j<=i;j++){ total=total+i; } } total=total+(k+1)*t; cout<<day<<' '<<total<<endl; } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator