Educational Codeforces Round 77 (Rated for Div. 2) B. Obtain Two Zeroes
Posted c4lnn
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Educational Codeforces Round 77 (Rated for Div. 2) B. Obtain Two Zeroes相关的知识,希望对你有一定的参考价值。
Link
题意:
已知 (a,b),任取 (x),每次进行两种操作的一种
操作一:(a-x,b-2x)
操作二:(a-2x,b-x)
问最终能否让 (a,b) 都为 (0)
思路:
易得成立的条件为:((a+b)mod3==0) && (max(a,b)le min(a,b) imes 2)
代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int T;cin>>T;
while(T--)
{
int a,b;
cin>>a>>b;
if((a+b)%3==0&&max(a,b)<=min(a,b)*2) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
以上是关于Educational Codeforces Round 77 (Rated for Div. 2) B. Obtain Two Zeroes的主要内容,如果未能解决你的问题,请参考以下文章
Educational Codeforces Round 7 A
Educational Codeforces Round 7
Educational Codeforces Round 90
Educational Codeforces Round 33