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. Coursera 吴恩达 机器学习 学习笔记

    Week 1 机器学习笔记(一)基本概念与单变量线性回归 Week 2   机器学习笔记(二)多元线性回归 机器学习作业(一)线性回归——Matlab实现 机器学习作业(一)线性回归——Python( ...

  2. PP: Toeplitz Inverse Covariance-Based Clustering of Multivariate Time Series Data

    From: Stanford University; Jure Leskovec, citation 6w+; Problem: subsequence clustering. Challenging ...

  3. C语言-无符号数与有符号数不为人知的秘密

    一.无符号数与有符号数 1.计算机中的符号位 数据类型的最高位用于标识数据的符号 -最高位为1,表明这个数为负数 -最高位为0,表明这个数为正数 #include <stdio.h> in ...

  4. 【转载】JS导出CSV文件

    转自:http://www.cnblogs.com/dengnan/p/3990211.html 通过自己实际测试有以下几种方法 方法一通过a标签实现,把要导出的数据用“\n”和“,”拼接成一个字符串 ...

  5. C++ log4cpp使用(转)

    参考文章: 1.常用C++库(1)日志库 https://blog.csdn.net/qilimi1053620912/article/details/87378707 2.一步步入门log4cpp  ...

  6. BOM笔记

    目录 BOM (浏览器对象模型) 简介 window对象 子对象 history 子对象 lacation 子对象 navigator 子对象 screen 子对象 frames BOM (浏览器对象 ...

  7. NG-ALAIN 边学边记1

    在文件夹下右键启动powerShell ng new my-project --skip-npm cd my-project ng add ng-alainnpm installng serve np ...

  8. Devexpress 18.2.7 破解

    1.破解文件下载 链接:https://pan.baidu.com/s/1DVANKYR3dBeHuc8DgPUihA 提取码:fyll 2.破解方式 解决压缩包,解压之后选中 DevExpress. ...

  9. 题解 CF712C 【Memory and De-Evolution】

    看到题我第一反应就是while循环 但是我竟然想正着推,失败,卡了十几分钟 后来我回来看到第三组测试数据 想到倒推 但是没坚持 于是我又卡了很久 过会我又回来想 AC了... 这个故事告诉我们,要努力 ...

  10. socket 简单实现HTTP服务器

    # -*- coding: utf-8 -*- # @Time : 2019-07-17 1:39 # @File : 网络socket实现http服务器.py # @Software: PyChar ...