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 |
很短的代码,哪位大侠可以看下哪里错了?所有的测试数据都搞对了啊In Reply To:通过的代码,看吧,很简单 Posted by:hahaxiao at 2005-09-03 09:08:00 #include<stdio.h> main() { int n,k,j,i,t,d,s=0; scanf("%d",&n); for(i=2;i<=45;i++) { s+=i; if(s>=n) break; } t=n-s+i; if(t==i) { for(j=2;j<=i-1;j++) printf("%d ",j+1); printf("%d",j+2); } else { for(j=2;j<i-t;j++) printf("%d ",j); for(k=1;k<t;k++,j++) printf("%d ",j+1); printf("%d",j+1); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator