| ||||||||||
| 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:dancia at 2005-04-04 20:31:14 划线的区域根本就不需要!
> 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;
> }
>
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator