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没想到一次AC#include<stdio.h> #include<math.h> main() {int n,i,s,sum=0,a[50]; scanf("%d",&s); n=(sqrt(8*s+9)-1)/2; for(i=2;i<=n;i++) a[i]=i; for(i=2;i<=n;i++) sum+=a[i]; while(sum<s) {--i; if(i<2)i=n; a[i]++,sum++; } for(i=2;i<=n;i++) printf("%d ",a[i]); puts(""); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator