标签:Zeroes case Educational Rated bb 2x aa choose test
B. Obtain Two Zeroes
time limit per test 1 second memory limit per test 256 megabytes input standard input output standard outputYou 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.
InputThe 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).
OutputFor 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).
Example input Copy3 6 9 1 1 1 2output Copy
YES NO YESNote
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=0;i<t;++i) { cin>>m>>n; if(m>n)swap(m,n); if((m+n)%3!=0||2*m<n) { cout<<"NO"<<endl; } else { cout<<"YES"<<endl; } } return 0; }
标签:Zeroes,case,Educational,Rated,bb,2x,aa,choose,test 来源: https://www.cnblogs.com/chrysanthemum/p/11949491.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。