Steps


Time Limit: 2 Seconds      Memory Limit: 65536 KB


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

For each test case, a line follows with two integers: 0 <= x <= y < 2^31.

Output

For each test case, print a line giving the minimum number of steps to get from x to y.

Sample Input



45 48

45 49

45 50

Sample Output



3

3

4


Source: University of Waterloo Local Contest 2000.01.29

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

#include<iostream>
using namespace std;
int main()
{
long a,b,d;
int c,step;
while(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<<step<<endl;
}
return 0;
}

最新文章

  1. Trace-语句启动Profiler中暂停的跟踪会出现什么状况
  2. Linux配置VNC实现远程图形化操纵
  3. 【iCore3 双核心板】iCore3封装库及使用说明V1.0
  4. ArrayList 排序Sort()方法扩展
  5. 通用的web系统数据导出功能设计实现(导出excel2003/2007 word pdf zip等)
  6. angular run()运行块
  7. libevent I/O示例
  8. 关于新版SDK报错You need to use a Theme.AppCompat theme的两种解决办法
  9. sublime text 2代码片段(Snippet)功能的使用
  10. Bzoj 2818: Gcd 莫比乌斯,分块,欧拉函数,线性筛
  11. POJ3630——简单Trie树
  12. javascript重点笔记
  13. 22个值得收藏的android开源码-UI篇
  14. JavaScript判断数组是否存在key
  15. Appium入门示例(Java)
  16. mybatis高级映射(一对一,一对多)
  17. 由js深拷贝引起的对内存空间的一些思考
  18. VS 附加到进程 加载“附加进程”弹窗很慢
  19. c#实现文件写入数据表/以二进制流保存到数据库,并实现下载
  20. dskinlite(uieasy mfc界面库)使用记录4:绘制动态元素(listbox)

热门文章

  1. Python 1-2模块的循环导入问题
  2. mysql解决 ERROR 1045 (28000): Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: YES)的报错
  3. scrapy实现全站抓取数据
  4. 窗口类WNDCLASSEX名词解析
  5. 3W法则-学习Docker
  6. 全排列函数 nyoj 366(next_permutation()函数)
  7. POJ1094 / ZOJ1060
  8. POJ 2096 找bug 期望dp
  9. noip模拟赛 数颜色
  10. Linux下汇编语言学习笔记26 ---