Codeforce |Educational Codeforces Round 77 (Rated for Div. 2) B. Obtain Two Zeroes
B. Obtain Two Zeroes
1 second
256 megabytes
standard input
standard output
You are given two integers aa and bb. You may perform any number of operations on them (possibly zero).
During each operation you should choose any positive integer xx and set a:=a−xa:=a−x, b:=b−2xb:=b−2x or a:=a−2xa:=a−2x, b:=b−xb:=b−x. Note that you may choose different values of xx in different operations.
Is it possible to make aa and bb equal to 00 simultaneously?
Your program should answer tt independent test cases.
The first line contains one integer tt (1≤t≤1001≤t≤100) — the number of test cases.
Then the test cases follow, each test case is represented by one line containing two integers aa and bb for this test case (0≤a,b≤1090≤a,b≤109).
For each test case print the answer to it — YES if it is possible to make aa and bb equal to 00 simultaneously, and NO otherwise.
You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES will all be recognized as positive answer).
3
6 9
1 1
1 2
YES
NO
YES
In the first test case of the example two operations can be used to make both aa and bb equal to zero:
- choose x=4x=4 and set a:=a−xa:=a−x, b:=b−2xb:=b−2x. Then a=6−4=2a=6−4=2, b=9−8=1b=9−8=1;
- choose x=1x=1 and set a:=a−2xa:=a−2x, b:=b−xb:=b−x. Then a=2−2=0a=2−2=0, b=1−1=0b=1−1=0.
题解:

CODE:
#include<iostream>
using namespace std;
int m ,n;
int main()
{
int t;
cin>>t;
for(int i=;i<t;++i)
{
cin>>m>>n;
if(m>n)swap(m,n);
if((m+n)%!=||*m<n)
{
cout<<"NO"<<endl;
}
else
{
cout<<"YES"<<endl;
}
}
return ;
}
Codeforce |Educational Codeforces Round 77 (Rated for Div. 2) B. Obtain Two Zeroes的更多相关文章
- 【cf比赛记录】Educational Codeforces Round 77 (Rated for Div. 2)
比赛传送门 这场题目前三题看得挺舒服的,没有臃肿的题目,对于我这种英语渣渣就非常友好,但因为太急了,wa了两发A后才意识到用模拟(可以删了,博主真的是个菜鸟),结果导致心态大崩 ---- 而且也跟最近 ...
- Educational Codeforces Round 77 (Rated for Div. 2) D A game with traps
题意:x正轴上有着一个陷阱的位置,开关和灵敏度,如果一个士兵灵敏度输给陷阱,他是过不去这个陷阱的幸运的是,你可以先过去把开关给关了,没错你是不怕陷阱的接下来呢你有操作,你移动一个,耗费一秒而你的团队需 ...
- Educational Codeforces Round 77 (Rated for Div. 2)
A: 尽可能平均然后剩下的平摊 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int ...
- Educational Codeforces Round 77 (Rated for Div. 2)D(二分+贪心)
这题二分下界是0,所以二分写法和以往略有不同,注意考虑所有区间,并且不要死循环... #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> ...
- Educational Codeforces Round 77 (Rated for Div. 2) - D. A Game with Traps(二分)
题意:$m$个士兵,每个士兵都有一个灵敏度$a[i]$,起点为$0$,终点为$n + 1$,在路上有$k$个陷阱,每个陷阱有三个属性$l[i],r[i],d[i]$,$l[i]$表示陷阱的位置,如果你 ...
- Educational Codeforces Round 77 (Rated for Div. 2) C. Infinite Fence
C. Infinite Fence 题目大意:给板子涂色,首先板子是顺序的,然后可以涂两种颜色,如果是r的倍数涂成红色,是b的倍数涂成蓝色, 连续的k个相同的颜色则不能完成任务,能完成任务则输出OBE ...
- Educational Codeforces Round 81 (Rated for Div. 2) C. Obtain The String
题目链接:http://codeforces.com/contest/1295/problem/C 题目:给定字符串s,t. 给定一个空串z,需要按照规则把z构造成 string z == stri ...
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...
随机推荐
- Ubuntu 安装nodejs最新版本
sudo apt update -y sudo apt install -y npm sudo npm config set registry https://registry.npm.tao ...
- ES5中的继承
继承 在面向对象的语言中, 大多语言都支持两种继承方式: 接口继承 和 实现继承, 接口继承 只继承方法签名, 实现继承 才继承实际的方法, ECMAScript 值支持 实现继承, 今天我们来谈谈实 ...
- JAVA知识点总结(六)(集合)
第十九章 集合 一.数组弊端: 数组长度是固定的,无法继续添加元素. 二.什么是集合: Java提供一个集合类,它的长度是可以改变的,能储存任意的对象,长度随着元素的增加而增加. 三.集合和数组的区别 ...
- [LeetCode] 135. 分发糖果
题目链接 : https://leetcode-cn.com/problems/candy/ 题目描述: 老师想给孩子们分发糖果,有 N 个孩子站成了一条直线,老师会根据每个孩子的表现,预先给他们评分 ...
- Structs2下的MyFirstTest
1.这是<Struts2-权威指南>第二章的例子 2.博文主要说明在eclipse下如何创建一个struts2项目 3.实现功能:在login.jsp输入用户名和密码,若用户名为scott ...
- 2019全国大学生数学建模竞赛(高教社杯)A题题解
文件下载:https://www.lanzous.com/i6x5iif 问题一 整体过程: 0x01. 首先,需要确定燃油进入和喷出的间歇性工作过程的时间关系.考虑使用决策变量对一段时间内燃油进入和 ...
- 华为云搭建windows+wordpress+xampp
1.如何将本地文件上传至华为云ECS云服务器(Windows系统) 1.1 在本地电脑上,快捷键“WIN+R"打开“运行”中输入“mstsc”,点击确定 1.2 在“远程桌面连接”框点击“ ...
- 【学习总结】快速上手Linux玩转典型应用-第1章-课程介绍
课程目录链接 快速上手Linux玩转典型应用-目录 1. Linux有什么用 2. 课程安排 3. 课程收获 基本运维能力,等等 END
- java上传文件-大文件以二进制保存到数据库
转自:https://blog.csdn.net/qq_29631069/article/details/70054201 1 一.创建表 oracle: create table baoxianda ...
- 以当前时间作为GUID的方法
在C#中,系统提供了GUID类,用户可以通过该类来获得128位的唯一标识,但是该标识不具有可读性,很难把该GUID显示在界面上,以当前时间精确到毫秒来作为GUID是一个比较不错的做法,但是DateTi ...