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 ...
随机推荐
- 更新代码 出现 You need to upgrade the working copy first 错误
今天更新了Eclipse的subclipse插件,更新代码报如下错误: svn: The working copy at 'E:\591woospace\kst_fashion_alipay_v1.2 ...
- JS 数组的常用方法详解归纳之改变原数组方法
shift() 把数组的第一个元素从其中删除,并返回第一个元素的值, 如果数组是空的,那么 shift() 方法将不进行任何操作,返回 undefined 值.请注意,该方法不创建新数组,而是直接修改 ...
- go io库
1 io.Reader和io.Writer的获取 tcp协议下的io.Reader是从conn中获取到的,因为要先建立conn,conn建立成功之后,然后读写数据. 2 真正的读写 2.1 io.Co ...
- (三)认识twisted reactor
一.reactor是单线程模型,简单粗暴,也就是说网络IO和我们的业务逻辑一般是在一个线程里,其中网络IO通过event loop的方式去异步执行,效率也很高.看下官网的这幅图,比较清晰 twiste ...
- 【Python】循环结构中的else
else在循环结构中,只有循环正常结束后才执行else,如果使用break跳出了循环,不会执行else for i in range(0,10): print(i)else: print(" ...
- 细说SQL Server数据类型
1.字符型 char 定长,查询速度快,最大8000字符(非unicode编码) ) '小明' 前四个字符存放‘小明’,后添6个空格补全 varchar 变长,最大8000字符(非unicode编码) ...
- 您的浏览器没有获得Java Virtual Machine(JVM)支持。可能由于没有安装JVM或者已安装但是没有启用。请安装JVM1.5或者以上版本,如果已安装则启用它。
您的浏览器没有获得Java Virtual Machine(JVM)支持.可能由于没有安装JVM或者已安装但是没有启用.请安装JVM1.5或者以上版本,如果已安装则启用它. https://www.j ...
- Tomcat报java.io.IOException: Broken pipe错误
Tomcat报java.io.IOException: Broken pipe错误,如下图: 解决方案:我的原因是因为网络策略导致出现该问题,即网络端口未启用或被限制.
- PAT Advanced 1005 Spell It Right (20 分)
Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output e ...
- Codeforces 931 概率DP
A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #def ...