Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

原来是我的n多加了1

Posted by myi_i at 2006-10-11 13:09:25 on Problem 1844
In 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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator