| ||||||||||
| 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 | |||||||||
Re:帮我看看错哪儿了吧,谢谢了!这题好像很简单,花不了您多少时间的!In Reply To:Re:帮我看看错哪儿了吧,谢谢了!这题好像很简单,花不了您多少时间的! Posted by:cpp050800448280 at 2005-04-03 10:26:08 my code:
#include <stdio.h>
#include <math.h>
#define sum(x) x*(x+1)/2
main()
{
int i,n,s;
scanf("%d",&s);
n=(1+(int)sqrt(-1+8*s))/2;
for(i=n;;i++)
if(sum(i-1)<s )
break;
((sum(i)-s)%2)?((i%2)?printf("%d",i+2):printf("%d",i+1)):printf("%d",i);
return 0;
}
> if((sum-m)%2) t=i+2 不对
> 要一位一位加
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator