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 wkf2014ict at 2014-10-06 15:08:41 on Problem 2590
In Reply To:单纯找规律水题,贴一个自己的代码吧。。。 Posted by:neofung at 2011-09-07 16:59:35
> #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