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

Re:为什么我这么做就老是超时?

Posted by bbflyer at 2005-08-16 10:23:39 on Problem 1844
In Reply To:为什么我这么做就老是超时? Posted by:myi_i at 2004-09-27 15:46:57
#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