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

吸取前人的经验(附代码)

Posted by zjp at 2009-08-23 09:46:18 on Problem 2590
#include <stdio.h>
    int main ()
    {
    	int n;int a,b;int sum;int flag;int i;
    	scanf("%d",&n);
    	while (n--)
    	{
    		sum=0;
    	 scanf ("%d %d",&a,&b);
    		flag=1;i=1;
            if (a==b)
				printf("0\n");
		else	
			
			for (;;)
    	  {  
              if (flag%2==1)

				sum=sum+i;
			  else 
			   {sum=sum+i;i=i+1;}
			 if (sum>=b-a)
			{printf("%d\n",flag);
    	  	     break;	}
		
    	   flag++;
    	  }		
    	  	
     }
    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