思路:
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;
}