POJ 2590:Steps

网友投稿 548 2022-10-04

POJ 2590:Steps

POJ 2590:Steps

Steps

Time Limit: 1000MS

 

Memory Limit: 65536K

Total Submissions: 7872

 

Accepted: 3612

Description

One steps through integer points of the straight line. The length of a step must be nonnegative and can be by one bigger than, equal to, or by one smaller than the length of the previous step.  What is the minimum number of steps in order to get from x to y? The length of the first and the last step must be 1.

Input

Input consists of a line containing n, the number of test cases.

Output

For each test case, a line follows with two integers: 0 <= x <= y < 2^31. For each test case, print a line giving the minimum number of steps to get from x to y.

Sample Input

3 45 48 45 49 45 50

Sample Output

3 3 4

Source

​​Waterloo local 2000.01.29​​

你  离  开  了  ,  我  的  世  界  里  只  剩  下  雨  。  。  。

#includeusing namespace std;int main(){ long a,b,d; int n,c,step; cin>>n; while(n--) { cin>>a>>b; d=b-a,c=1,step=0; while(1) { if(d<2*c)break; else { d=d-2*c; step+=2; c++; } } if(d>c)step+=2; else if(d<=0)step+=0; else step+=1; cout<

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:小程序深度解读
下一篇:jsapi支付什么意思(js支付是什么)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~