Codeforces 1260B Obtain Two Zeroes
思路:
1.题意要使a和b同时减到0,我们设每次x都为1,因为x大于1的减法都可以由x=1的减法组成;
2.设a=a-1&b=b-2有m次,a=a-2&b=b-1有n次,问题即转化为关于m和n的方程组
有非负整数解;
代码:
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
IOS;
int t; cin>>t;
while(t--){
LL a,b; cin>>a>>b;
if((2*b-a)%3==0&&(2*a-b)%3==0&&(2*b-a)>=0&&(2*a-b)>=0) puts("YES");
else puts("NO");
}
return 0;
}

浙公网安备 33010602011771号