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

WA啊,哪位好心的大哥能指点一下啊!万分感谢!

Posted by jiabiao at 2006-04-18 13:17:30 on Problem 2590
#include<stdio.h>
int main()
{
  long n,x,y,i,count,flag;
  scanf("%ld",&n);
  for(i=0;i<n;i++)
  {
     count=2;
     flag=2;
     scanf("%ld %ld",&x,&y);
     x++;y--;
     if(y<x||y==x)
     {
       printf("1\n");
       continue;
     }
     while(y>x)
     {
        if(x+flag>=y)
        {
           count++;
           break;
        }
        if(x+flag<y)
        {
           x=x+flag;y=y-flag;
           count=count+2;
           flag++;
        }
     }
     printf("%ld\n",count);
  }
  return 0;
}

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