| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
建个数组就可以了!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator