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> using namespace std; int main() { long i,j,a,b(0),k,c[1001]; while(cin>>a) { for( i = 2; b <= a; i++ ) { b+=i; c[i]=i; } c[i]=i; j=i; if( b==a ) { for( i=2; i < j; i++ ) cout<<c[i]<<'\0'; } else { if( b - a == 1 ) { for( i = j; i > 2; i-- ) if( b + j - 2 - i == a ) { k=i; break; } for( i = 3; i < k; i++ ) cout<<c[i]<<'\0'; for( i = k + 1; i < j + 1; i++ ) cout<<c[i]<<'\0'; cout<<endl; } else { for( i = 2; i < b - a; i++ ) cout<<c[i]<<'\0'; for( i = b - a + 1; i<j ; i++ ) cout<<c[i]<<'\0'; cout<<endl; } } b=0; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator