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. Java基础-运算符、包机制、JavaDoc生成文档

    运算符 Java语言支持如下运算符:优先级() 算术运算符:+,-,*,/,%,++,- 赋值运算符:= 关系运算符:>,<,>=,<=,==,!=,instanceof 逻辑 ...

  2. boost.python编辑,以及c++api的python封装

    boost.python 编辑与踩坑 踩坑1.编辑的版本使用的vs版本不同的话,使用的命令不同 2.编辑第一条命令b2 toolset=msvc-11.0 --with-python报错:fatal ...

  3. ES实战- data too large, data for

    场景 客户现场业务系统突然查询不到数据,个人一开始分析以为是聚合查询报错,于是去看了下系统日志,看到如下日志打印: Caused by: ElasticsearchStatusException[El ...

  4. RocketMQ学习笔记

    RocketMQ学习笔记 RocketMQ学习参考官网文档:https://github.com/apache/rocketmq/tree/master/docs/cn . 由于RocketMQ是有国 ...

  5. Mybatis二级缓存(1)

  6. IDEA报错Error running ‘Application‘: Command line is too long解决方案

    IDEA报错Error running 'Application': Command line is too long.Shorten command line for Application or ...

  7. python之目录结构01

    本文档主要是自己学习巩固以及复习之用,主要写些自己的学习体会! 以下为一个简要的目录构: Foo/ |-- bin/ | |-- foo | |-- foo/ | |-- tests/ | | |-- ...

  8. Vue中使用model属性

    model属性接收两个参数 类型:{ prop?: string, event?: string } prop 也就是调用该组件的父组件中使用v-model指令绑定的属性 event 对应的是修改pr ...

  9. WCF的实现(方式二)

    参考他人实现文件传输 [WCF]利用WCF实现上传下载文件服务 服务端: 1.首先新建一个名为FileService的WCF服务库项目,如下图: 2.将Service,IService重命名为File ...

  10. 使用myBadboy(python自主开发工具)启动谷歌浏览器并自动录制jmeter脚本

    一.源代码下载 https://gitee.com/rmtic/mybadboy 说明:因现有的录制方法有不能定制等不足之处,所以自力更生,自动生成对应jmeter脚本,减少维护成本 二.操作说明 1 ...