| ||||||||||
| 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 | |||||||||
原来是我的n多加了1In Reply To:Re:为什么我这么做就老是超时? Posted by:bbflyer at 2005-08-16 10:23:39 > #include<stdio.h>
> main()
> {
> int i,n,r;
> while(scanf("%d",&n)!=EOF)
> {
> r=0;
> for(i=1;;i++)
> {
> r+=i;
> if(r>=n)
> break;
> }
> if((r-n)%2)
> {
> if(i%2)
> i+=2;
> else
> i+=1;
> }
> printf("%d\n",i);
> }
> }
> //一句话,找规律
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator