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 neofung at 2011-09-07 16:59:35 on Problem 2590
#include <stdio.h>

int main(void)
{
	int ncases;
	int a,b,len;
	scanf("%d",&ncases);

	while(ncases--)
	{
		scanf("%d %d",&a,&b);
		len=b-a;

		int temp=0;
		int index;
		for(int i=0;;++i)
		{
			if(len<=temp+(i+1)/2)
			{
				index=i;
				break;
			}
			temp+=(i+1)/2;
		}
		printf("%d\n",index);
	}

	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