2019_GDUT_新生专题I选集 L Codeforces-1260B
题目:
You are given two integers a and b. You may perform any number of operations on them (possibly zero).
During each operation you should choose any positive integer x and set a:=a−x, b:=b−2x or a:=a−2x, b:=b−x. Note that you may choose different values of x in different operations.
Is it possible to make a and b equal to 0 simultaneously?
Your program should answer t independent test cases.
Input
The first line contains one integer t (1≤t≤100) — the number of test cases.Then the test cases follow, each test case is represented by one line containing two integers a and b for this test case (0≤a,b≤10e9).’
Output
For each test case print the answer to it — YES if it is possible to make a and b equal to 0 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).
Example
Input
3
6 9
1 1
1 2
Output
YES
NO
YES
做法:数学题。每次操作的x都是相等的,也就是每次总共都减去了3个x,所以a+b应当是3的倍数。假设全部选择操作a:=a−2x, b:=b−x,会发现当a=2*b 的时候刚好可以为0,当a>2b的时候无论如何也没办法完成操作,b>2a同理。
代码:
#include<iostream>
#include<cstdio>
using namespace std;int main()
{int T;long long a,b;cin>>T;while (T--){cin>>a>>b;if ((a+b)%3==0 && (b<=2*a && a<=2*b))cout<<"YES"<<endl;else cout<<"NO"<<endl;}return 0;
}
2019_GDUT_新生专题I选集 L Codeforces-1260B相关推荐
- 2019_GDUT_新生专题I选集——C
题目:[POJ]1979 ----Red and Black 原题连接:http://poj.org/problem?id=1979 题目描述:给出一个图,其中有主人公(@),障碍物(#),可移动区域 ...
- 2019_GDUT_新生专题V算法优化 F. Expedition POJ 2431
题目: Language: Expedition Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 31110 Accepted: ...
- 2019_GDUT_新生专题V算法优化 B. A Simple Problem with Integers POJ 3468
来源 POJ3468 题目: You have N integers, A1, A2, - , AN. You need to deal with two kinds of operations. O ...
- 2019_GDUT_新生专题IV数论 G
题目:美素数 题目链接:https://vjudge.net/contest/351853#problem/G 题目描述: 美素数:各位相加后,依然是素数. 在给出区间内找美素数的个数. 1.得出素数 ...
- 2019 GDUT 新生专题Ⅲ L题
L - Til the Cows Come Home 题目链接 题目大意:已知给出部分点的边权值,计算从N点到1点的最短路. 思路:单源最短路,当然直接dijkstra模板啦. 代码 #include ...
- [kuangbin带你飞]专题六 最小生成树 L - 还是畅通工程 (简单最小生成树)
L - 还是畅通工程 题目链接:https://vjudge.net/contest/66965#problem/L 题目: 某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离.省政府&qu ...
- 2021_GDUT_新生专题训练_数据结构
基础数据结构 链表 基础结构 struct TypeNode {int value;TypeNode* next; }; 特点:可延展性,失去了数组随机读取的优点,同时链表由于增加了结点的指针域,空间 ...
- 2021_GDUT_新生专题训练_数论
G - 美素数 小明对数的研究比较热爱,一谈到数,脑子里就涌现出好多数的问题,今天,小明想考考你对素数的认识.问题是这样的:一个十进制数,如果是素数,而且它的各位数字和也是素数,则称之为"美 ...
- 2019 GDUT 新生专题Ⅰ C题
C - DFS/BFS 题目 There is a rectangular room, covered with square tiles. Each tile is colored either r ...
- kuangbin带你飞专题合集
题目列表 [kuangbin带你飞]专题一 简单搜索 [kuangbin带你飞]专题二 搜索进阶 [kuangbin带你飞]专题三 Dancing Links [kuangbin带你飞]专题四 最短路 ...
最新文章
- 给python初学者的最好练手项目-Python的练手项目有哪些值得推荐?(知乎转载)...
- 指针-数组传参,指针传参
- 正则表达式的汉字匹配
- java搭建maven项目_Eclipse使用maven创建Java Web项目完整示例
- 性能测试培训:定位jvm耗时函数
- 利用 livy 远程提交 spark作业
- Docker使用link建立容器之间的连接
- 简单的Jenkins配置tomcat
- 2. 大数据感知与获取
- iRedMail批量用户添加命令
- WEB应用组合——LAMP软件源码编译安装
- java项目远程调用别的项目接口
- 2022idea报错快速解决方法图解:Invocation error: unable to read askpass response from ‘C:\Users\QKN\AppDat
- 字节跳动、腾讯、阿里的社交战,浑水中依然没有赢家
- 使用Unity调用派样机技术小结
- 仔细体验,我想从产品设计的角度分析分析微信的声音锁
- mysql弱类型_PHP弱类型及相关函数Bypass
- android开发笔记之有用软件列表
- [Python] 数据预处理(缺失值、异常值、重复值) [相关方法参数说明、代码示例、相关概念]
- 转:rsync远程备份实测和总结