A - Add Odd or Subtract Even
A - Add Odd or Subtract Even



思路:其实认真观察就能发现,这个与输入的书有关系,且答案为0,1,2。先看相同,不用加减,为0,再看前小后大,因为加奇数减偶数,如果,相差奇数,为1,相差偶数,为2,同理可得前大后小的答案。
代码:
#include<iostream>
#include<cmath>
using namespace std; int main(){
std::ios::sync_with_stdio(false);
int a, b, sum, n;
cin >> n;
while (n--){
cin >> a >> b;
if (a == b)
cout << "0" << endl; else if (a < b){
sum = b - a;
if (sum % 2 == 0)
cout << "2" << endl;
else
cout << "1" << endl;
}
else{
sum = a - b;
if (sum % 2 == 0)
cout << "1" << endl;
else
cout << "2" << endl;
}
}
return 0;
}
A - Add Odd or Subtract Even的更多相关文章
- Codeforce 1311A Add Odd or Subtract Even
Add Odd or Subtract Even time limit per test2 seconds memory limit per test256 megabytes inputstanda ...
- [CF1311A] Add Odd or Subtract Even
Solution a<b, delta=odd, ans=1 a<b, delta=even, ans=2 a=b ans=0 a>b, delta=odd, ans=2 a> ...
- 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: ...
- deep_learning_Function_tf.add()、tf.subtract()、tf.multiply()、tf.div()
tf.add().tf.subtract().tf.multiply().tf.div()函数介绍和示例 1. tf.add() 释义:加法操作 示例: x = tf.constant(2, dtyp ...
- Codeforces补题2020.2.28(Round624 Div 3)
A.Add Odd or Subtract Even 签到题~ #include<bits/stdc++.h> using namespace std; int T; int a,b; i ...
- Codeforces Round #624 (Div. 3)(题解)
A. Add Odd or Subtract Even 思路: 相同直接为0,如果两数相差为偶数就为2,奇数就为1 #include<iostream> #include<algor ...
- HDU 4919 Exclusive or 数学
题意: 定义 \[f(n)=\sum\limits_{i=1}^{n-1}(i\oplus (n-i))\] 求\(f(n),n \leq 10^{500}\) 分析: 这个数列对应OEIS的A006 ...
- 缓冲区溢出利用——捕获eip的傻瓜式指南
[译文] 摘要:为一个简单的有漏洞程序写一个简单的缓冲区溢出EXP,聚焦于遇到的问题和关键性的教训,提供详细而彻底的描述 内容表:1. I pity the fool, who can't smash ...
- [开源].NET数据库访问框架Chloe.ORM
扯淡 13年毕业之际,进入第一家公司实习,接触了 EntityFramework,当时就觉得这东西太牛了,访问数据库都可以做得这么轻松.优雅!毕竟那时还年轻,没见过世面.工作之前为了拿个实习机会混个工 ...
- Beginning Scala study note(4) Functional Programming in Scala
1. Functional programming treats computation as the evaluation of mathematical and avoids state and ...
随机推荐
- Ubuntu20.04 LTS更新源
Ubuntu 20.04 LTS Focal Fossa于2020年04月23日发布. 备份sudo cp /etc/apt/sources.list /etc/apt/sources.list.ba ...
- 广告网络归因技术之SKAdNetwork
IDFA的背景 为了保护用户隐私,早在2012年就不再允许其生态中的玩家获取用户的唯一标识符,但是商家在移动端打广告的时候又希望能监控到每一次广告投放的效果,因此,苹果想出了折中的办法,就是提供另外一 ...
- go开发框架推荐
根据自己了解的情况,从易用性和文档完善程度来说,推荐优先考虑使用如下框架: fiber revel echo iris gin beego 以revel作为入门教程,在go项目的根文件夹里执行下面2条 ...
- 51电子-STC89C51开发板:汇编教程
全部内容请点击目录列表查看: 51电子-STC89C51开发板:<目录> --------------------------- 正文开始 ---------------------- ...
- 内存模型--共享、JMM
Balking 指令重排
- xss-labs
level1 <h1 align=center>欢迎来到level1</h1> <h2 align=center>欢迎用户te111</h2><c ...
- windows下BAT实现守护进程
通过bat守护特定exe @echo off :start choice /t 5 /d y /n >nul tasklist|find /i "程序名称.exe" if E ...
- 数据库管理工具navicat16.0安装
//-----------------*****本文章只做学习参考,侵权立删*****-----------------\\ 总结概要如下: 1.完成安装包下载后,点击navicat160_premi ...
- Cleanest XMaster绿色解压最新版下载9.6密钥激活码
cad安装报错换了好几个版本都不行,用这个卸载了一下,确实有用 Cleanest XMaster绿色版cad卸载工具分享下载 地址一(百度网盘) 地址二(直接下载) 9.6.05密钥:[AtrXShX ...
- CRC校验模板
#ifndef CRC_H #define CRC_H #include "main.h" #ifdef CRC_C #endif typedef struct { uchar R ...