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的更多相关文章

  1. Codeforce 1311A Add Odd or Subtract Even

    Add Odd or Subtract Even time limit per test2 seconds memory limit per test256 megabytes inputstanda ...

  2. [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> ...

  3. 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: ...

  4. 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 ...

  5. 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 ...

  6. Codeforces Round #624 (Div. 3)(题解)

    A. Add Odd or Subtract Even 思路: 相同直接为0,如果两数相差为偶数就为2,奇数就为1 #include<iostream> #include<algor ...

  7. HDU 4919 Exclusive or 数学

    题意: 定义 \[f(n)=\sum\limits_{i=1}^{n-1}(i\oplus (n-i))\] 求\(f(n),n \leq 10^{500}\) 分析: 这个数列对应OEIS的A006 ...

  8. 缓冲区溢出利用——捕获eip的傻瓜式指南

    [译文] 摘要:为一个简单的有漏洞程序写一个简单的缓冲区溢出EXP,聚焦于遇到的问题和关键性的教训,提供详细而彻底的描述 内容表:1. I pity the fool, who can't smash ...

  9. [开源].NET数据库访问框架Chloe.ORM

    扯淡 13年毕业之际,进入第一家公司实习,接触了 EntityFramework,当时就觉得这东西太牛了,访问数据库都可以做得这么轻松.优雅!毕竟那时还年轻,没见过世面.工作之前为了拿个实习机会混个工 ...

  10. Beginning Scala study note(4) Functional Programming in Scala

    1. Functional programming treats computation as the evaluation of mathematical and avoids state and ...

随机推荐

  1. MySQL简介&通用语法&分类

    一.SQL简介 1.结构化查询语言,一门操作关系型数据库的编程语言 2.定义操作所有关系型数据库的统一标准 3.对于同一个需求,每一种数据库操作的方式可能会存在一些不一样的地方,我们称为"方 ...

  2. SignalR+Redis,SignalR+Sqlserver集群部署应对海量链接

    一:SignalR+Sqlserver 1:新建一个MVC的空项目和之前一样 2:index页面的js代码如下 <script src="~/Scripts/jquery-1.10.2 ...

  3. C语言II博客作业04

    C语言II-作业04 作业头 这个作业属于哪个课程 https://edu.cnblogs.com/campus/zswxy/SE2020-2/?page=2 这个作业要求在哪里 https://ed ...

  4. Linux 第七节( 磁盘配额,RAID )

    vim /etc/fstab    //编辑文件 UUID=xxxxxxxxxxxxxx /boot xfs defaults,uquota 0 0    //增加uqota命令,允许磁盘扩容 ino ...

  5. string中的stoi()函数

    1094 谷歌的招聘 (20分) 本题要求你编程解决一个更通用的问题:从任一给定的长度为 L 的数字中,找出最早出现的 K 位连续数字所组成的素数. 输入格式: 输入在第一行给出 2 个正整数,分别是 ...

  6. pritunl zero 零信任系统

    pritunl zero 零信任系统 一.概述 1.介绍 Pritunl Zero是一个零信任系统,它可以在不使用VPN的情况下从不受信任的网络安全地访问内部服务. 2.背景 内网搭建了类百度文库系统 ...

  7. Ginan-PEA例程下载

    输入以下命令可在Ubuntu系统中进行下载,但受到网络限制并不能有效下载或者下载很慢 python3 scripts/download_examples.py 通过阅读python脚本,可将下载网址拷 ...

  8. MyBatis(Plus) 打印SQL, 分析执行时间

    MyBatis/MyBatis Plus打印的SQL调试起来比较麻烦 当然IDEA/eclipse都有类似mybatis log plugin这种插件来解析, 但是安装插件有些许弊端, 就写了个工具类 ...

  9. excel数字转日期

    import datetime delta = datetime.timedelta() today = datetime.datetime.strptime('1899/12/30', '%Y/%m ...

  10. vue打包添加时间戳,实现更新项目自动清除缓存

    本来vue打包会自动用chunkhash来解决缓存问题,但是部分浏览器不会自动更新,因此可以通过后面t=${ }的不同来实现自动重新加载文件,保持最新的界面 (1).webpack打包:修改build ...