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 tcxgsy at 2005-08-19 17:19:55 on Problem 2590
In Reply To:我再三考虑过后,仍是不对? Posted by:tcxgsy at 2005-08-19 16:34:34
#include"stdio.h"
#include"math.h"

main()
{int n;
 long x,y,z,k,j=0,p=0;
    scanf("%d",&n);
    while(n)
    {   scanf("%d%d",&x,&y);
       z=y-x;k=0;
       for(p=1;;p++)
          {  k+=p;
              j++;
              if(z<=(2*k))  break;
           }
       if(z<(2*k-j)) printf("%ld\n",(2*j-2));
          else  
                  if(z<2*k) printf("%ld\n",2*j-1);
                 else printf("%ld\n",2*j);        
        n--;
      }
 }

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