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 |
真是服了 cout 和printf换换样就不对了 c++又不支持cout<<了吗?真是的#include<iostream> #include<memory.h> using namespace std; __int64 num[11000]; int main() { int i,n,j; int temp=0; memset(num,0,sizeof(num)); for(i=1;i*(i-1)/2<11000;i++) { temp=(i-1)*i/2; for(j=1;j<=i;j++) { num[temp+j]=i+num[temp+j-1]; } } for(temp=temp+i-1;temp<11000;temp++) num[temp]=i+num[temp-1]; //for(i=1;i<30;i++) // cout<<num[i]<<" "; while(scanf("%d",&n)&&n) { // cout<<n<<" "<<num[n]<<endl; printf("%d %d\n",n,num[n]); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator