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. 2023 新年FLAG 当你无所事事的时候,打开本博客看看,置顶着呢,别说你看不到,摸鱼狗

    2023.2.15 接触到了Visual Grounding,但是是3D的,不知道这是不是冥冥之中的一颗种子,我现在有强烈的直觉我未来就是搞这个方向. 2023.2.14 回到学校正式开始工作 OK, ...

  2. Eclipse编程工具的使用( for Jave EE )

    一.下载安装 Eclipse IDE for Java EE Developers 1.1 下载 官方下载:https://www.eclipse.org/downloads/ 推荐下载2021-09 ...

  3. Error occurred while proxying request localhost:端口 报错500的解决方法

    '/AuthServer/api/': { target: 'https://localhost:44319', secure:false,// 这是签名认证,http和https区分的参数设置 ch ...

  4. <string> <cstring> <string.h>

    <string>是C++标准库头文件,包含了拟容器class std::string的声明(不过class string事实上只是basic_string<char>的type ...

  5. this指向问题大全和call,apply,bind详解

    详细笔记链接:https://www.jianshu.com/p/bc541afad6ee 函数内外作用域问题: var a = 1function f1(){ var a = 2 console.l ...

  6. 使用ADB拷贝Android设备的文件夹

    在当前目录下执行,拷贝到当前目录.   拷贝照片 adb pull sdcard/DCIM   删除照片 adb shell rm -rvf sdcard/DCIM   拷贝图片 adb pull s ...

  7. yolov5查看训练日志图片和直方图(包括稀疏训练bn直方图)

    0.D:\code\codePy\yolov5-6.1\runs\train\exp25文件夹下有 events.out.tfevents.1675823043.DESKTOP-ACC9FL4.521 ...

  8. shell脚本,shell语法和结构(以Cshell/TC shell为例)

    1.C shell/TC shell常用语法和结构 (1) shbang行: #!/bin/sh,通知内核使用哪种内核解释脚本; #!/bin/csh 或 #!/bin/tcsh (2) 注释: 以# ...

  9. JSP课设:学生选课系统(附源码+调试)

    JSP学生选课管理系统学生选课管理系统功能概述(1)登录模块分为两种角色:学生角色.教师角色 (2)教师模块:选课管理功能为对课程信息(课程编号.名称.学分)进行添加.修改.删除操作:学生信息功能对学 ...

  10. 性能测试记录: ZZ 只改5行代码获得10倍吞吐量提升

    首先得找台足够性能的机器来测试,性能不足时代码运行会出现各种奇怪的现象,导致浪费时间 文章: https://www.jianshu.com/p/4cd8596352ad   只改了5行代码吞吐量提升 ...