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 |
跟AC的代码几乎一样,只改了一点点,就WA,WA得我一头雾水,大家来看看代码哈#include <stdio.h> int main() { register int i,j; int sum,qq,n; scanf("%d",&n); i=2; sum=2; while(sum<=n) { i++; sum+=i; } sum-=i; i--; qq=i; if(sum==n){ printf("2"); for(i=3;i<=qq;i++) printf(" %d",i); } else { qq++; j=qq-(n-sum); if(j==2) { printf("3"); for(i=4;i<=qq;i++) printf(" %d",i); } else { printf("2"); for(i=3;i<j;i++) printf(" %d",i); for(i=j+1;i<=qq;i++) printf(" %d",i); } } printf("\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