暴力模拟....
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long int LL;
int main()
{
int T_T;
scanf("%d",&T_T);
while(T_T--)
{
LL n,k,d1,d2,RES,res;
scanf("%I64d%I64d%I64d%I64d",&n,&k,&d1,&d2);
RES=n-k;
bool flag=false;
///cas 00
LL low=d1+d1+d2;
if(k>=low&&(k-low)%3==0)
{
res=RES;
if(res>=d1+2*d2)
{
res-=d1+2*d2;
if(res%3LL==0)
{
flag=true;
puts("yes");
continue;
}
}
}
///cas 11
low=d2+d2+d1;
if(k>=low&&(k-low)%3==0)
{
res=RES;
if(res>=d2+d1*2)
{
res-=d2+2*d1;
if(res%3LL==0)
{
flag=true;
puts("yes");
continue;
}
}
}
///cas 10
if(d1>=d2)
{
low=d1+d1-d2;
if((k-low>=0&&(k-low)%3==0))
{
res=RES;
if(res>=d1+d2)
{
res-=d1+d2;
if(res%3LL==0)
{
flag=true;
puts("yes");
continue;
}
}
}
}
else
{
low=d2+d2-d1;
if((k-low>=0&&(k-low)%3==0))
{
res=RES;
if(res>=d1+d2)
{
res-=d1+d2;
if(res%3LL==0)
{
flag=true;
puts("yes");
continue;
}
}
}
}
///cas 01
if(k>=d1+d2&&(k-d1-d2)%3==0)
{
res=RES;
if(d1>d2)
{
if(res>=d1+(d1-d2))
{
res-=d1+(d1-d2);
if(res%3LL==0)
{
flag=true;
puts("yes");
continue;
}
}
}
else
{
if(res>=d2+(d2-d1))
{
res-=d2+(d2-d1);
if(res%3LL==0)
{
flag=true;
puts("yes");
continue;
}
}
}
}
if(flag==false)
puts("no");
}
return 0;
}