You are given two positive integers aa and bb .

In one move, you can change aa in the following way:

  • Choose any positive odd integer xx (x>0x>0 ) and replace aa with a+xa+x ;
  • choose any positive even integer yy (y>0y>0 ) and replace aa with a−ya−y .

You can perform as many such operations as you want. You can choose the same numbers xx and yy in different moves.

Your task is to find the minimum number of moves required to obtain bb from aa . It is guaranteed that you can always obtain bb from aa .

You have to answer tt independent test cases.

Input

The first line of the input contains one integer tt (1≤t≤1041≤t≤104 ) — the number of test cases.

Then tt test cases follow. Each test case is given as two space-separated integers aa and bb (1≤a,b≤1091≤a,b≤109 ).

Output

For each test case, print the answer — the minimum number of moves required to obtain bb from aa if you can perform any number of moves described in the problem statement. It is guaranteed that you can always obtain bb from aa .

Example
Input

 
5
2 3
10 10
2 4
7 4
9 3
Output

 
1
0
2
2
1
判断几次就行了。
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int a,b;
cin>>a>>b;
if(b>a)
{
if((b-a)%!=)
{
cout<<<<endl;
continue;
}
else
{
cout<<<<endl;
continue;
}
}
else if(b==a)
{
cout<<<<endl;
continue;
}
else
{
if((a-b)%!=)
{
cout<<<<endl;//a先加上1变成偶数
continue;
}
else cout<<<<endl;
continue;
}
}
return ;
}

Codeforces Round #624 (Div. 3) A. Add Odd or Subtract Even(水题)的更多相关文章

  1. Codeforces Round #356 (Div. 2)B. Bear and Finding Criminals(水题)

    B. Bear and Finding Criminals time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  2. Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake 水题

    A. Far Relative's Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/A Description Do ...

  3. Codeforces Round #385 (Div. 2) A. Hongcow Learns the Cyclic Shift 水题

    A. Hongcow Learns the Cyclic Shift 题目连接: http://codeforces.com/contest/745/problem/A Description Hon ...

  4. Codeforces Round #396 (Div. 2) A. Mahmoud and Longest Uncommon Subsequence 水题

    A. Mahmoud and Longest Uncommon Subsequence 题目连接: http://codeforces.com/contest/766/problem/A Descri ...

  5. Codeforces Round #375 (Div. 2) A. The New Year: Meeting Friends 水题

    A. The New Year: Meeting Friends 题目连接: http://codeforces.com/contest/723/problem/A Description There ...

  6. Codeforces Round #258 (Div. 2) C. Predict Outcome of the Game 水题

    C. Predict Outcome of the Game 题目连接: http://codeforces.com/contest/451/problem/C Description There a ...

  7. Codeforces Round #359 (Div. 2) B. Little Robber Girl's Zoo 水题

    B. Little Robber Girl's Zoo 题目连接: http://www.codeforces.com/contest/686/problem/B Description Little ...

  8. Codeforces Round #358 (Div. 2) B. Alyona and Mex 水题

    B. Alyona and Mex 题目连接: http://www.codeforces.com/contest/682/problem/B Description Someone gave Aly ...

  9. 【打CF,学算法——二星级】Codeforces Round #313 (Div. 2) B. Gerald is into Art(水题)

    [CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/B 题面: B. Gerald is into Art time limit per t ...

随机推荐

  1. BZOJ3680 JSOI2004 平衡点 - 随机/近似算法

    迭代乱搞了下就过了…… #include <bits/stdc++.h> using namespace std; ],y[],w[]; double xm,ym,wt,k,lambda= ...

  2. 给IDEA添加右键打开功能

    添加文件夹右键程序打开 开始运行regedit 找到 HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell 1.右键shell目录新建项Idea 2. ...

  3. VMware该虚拟机似乎正在使用中。如果该虚拟机未在使用,请按“获取所有权(T)”按钮获取它的所有权

    原文链接:https://blog.csdn.net/helloxiaozhe/article/details/81176684 VMware该虚拟机似乎正在使用中.如果该虚拟机未在使用,请按“获取所 ...

  4. c++ char*和wchar*互相转换(转)

    原文地址: 1.c++ char*和wchar*互相转换 2.C++ WINDOWS下 wchar_t *和char * 相互转化总结篇

  5. Chrome 提标 您的浏览器限制了第三方Cookie...解决方法

    最近升级Chrome后会出现  您的浏览器限制了第三方Cookie,这将影响您正常登录,您可以更改浏览器的隐私设置,解除限制后重试. 解决方法: chrome://flags/ 把这句复制到浏览器回车 ...

  6. AST抽象语法树——最基础的javascript重点知识,99%的人根本不了解

    AST抽象语法树——最基础的javascript重点知识,99%的人根本不了解 javascriptvue-clicommonjswebpackast  阅读约 27 分钟 抽象语法树(AST),是一 ...

  7. C++-指针阅读能力提升

    下面的标识符你肯定在工程中看不到,但是在面试题中却非常常见,掌握掌握还是不错的. int (*p1)(int*, int (*f)(int*));              int (*p2[5])( ...

  8. Java Web代码审计流程与漏洞函数

    常见框架与组合 常见框架 Struts2 SpringMVC Spring Boot 框架执行流程 View层:视图层 Controller层:表现层 Service层:业务层 Dom层:持久层 常见 ...

  9. tomcat8.5和redis实现session共享

    1. 问题 ​ 由于之前看其他资料配置的session共享没注意自己tomcat的版本所以出现了诸多问题,tomcat8.5和之前版本的配置是不一样的. 2. 配置 ​ ①将如图所示三个jar包放入t ...

  10. C++ vector的用法(转)

    原文链接:https://blog.csdn.net/qinyuehong/article/details/92837359