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 ocgcn at 2011-01-25 15:57:57 on Problem 2590
#include<iostream>
using namespace std;
int a[65540];
int main(){
	int i=1;
	while(a[i-1]>=0){
		if(i%2)
			a[i]=(i+1)*(i+1)/4;
		else a[i]=i*(i+2)/4;
		i++;}
	int j,n,x,y,d;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x>>y;
		if(x==y) {cout<<0<<endl;continue ;}
		d=y-x;
		j=1;
		while(d>a[j]) j++;
		cout<<j<<endl;
	}
}

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