Codeforces Round #624 (Div. 3) A. Add Odd or Subtract Even(水题)
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.
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 ).
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 .
5
2 3
10 10
2 4
7 4
9 3
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(水题)的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 【打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 ...
随机推荐
- Navicat Premium怎么设置字段的唯一性(UNIQUE)?
参考链接:https://blog.csdn.net/Song_JiangTao/article/details/82192189 1.打开你想要设计的表 这里写图片描述2.清楚你想要设计哪个字段为唯 ...
- VUE 路由参数改变重新刷新数据
VUE 路由参数改变重新刷新数据 App.vue 里面使用路由,然后通过App.vue文件中的搜索功能搜索刷新路由文件中的列表. 修改 index.js 文件 首先在路由文件 index.js 文件中 ...
- 机器学习作业(三)多类别分类与神经网络——Python(numpy)实现
题目太长了!下载地址[传送门] 第1题 简述:识别图片上的数字. import numpy as np import scipy.io as scio import matplotlib.pyplot ...
- centos7添加多个网段
# service network restart是重启所有网卡.例如下面的例子:>ifconfig eth0 up|down>service network restart|start| ...
- [HAOI2011] 向量 - 裴蜀定理
给你一对数a,b,你可以任意使用(a,b), (a,-b), (-a,b), (-a,-b), (b,a), (b,-a), (-b,a), (-b,-a)这些向量,问你能不能拼出另一个向量(x,y) ...
- normalization flow
from Eric Jang Normalizing flows transform simple densities (like Gaussians) into rich complex distr ...
- DE1_MSEL
基础的一般实验:01001(现在用的)或10010 马上换linux,做个记录: sd卡启动linux系统时,启动开关0至4位拨至00000
- 前端框架-Vue 入门
一.介绍 1.Vue.js 是什么 Vue (读音 /vjuː/,类似于 view) 是一套用于构建用户界面的渐进式框架. Vue 的核心库只关注视图层,不仅易于上手,还便于与第三方库或既有项目整合. ...
- Energy Consumption Of Low-Pressure Crystal Craft Lights
What kind of place is the low-pressure crystal light generally suitable for? Low-pressure crystal li ...
- stopPropagation() 方法
定义和用法 不再派发事件. 终止事件在传播过程的捕获.目标处理或起泡阶段进一步传播.调用该方法后,该节点上处理该事件的处理程序将被调用,事件不再被分派到其他节点. 语法 event.stopPropa ...