fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here;
  6. int t;
  7. cin>>t;
  8. while(t--)
  9. {
  10. long long int a,b,c;
  11. cin>>a>>b>>c;
  12. if(a>2){
  13. long long int e=(a+2)%4,j;
  14. long long int q=(b+c)%10;
  15. if(e==0)j=6;
  16. if(e==1)j=2;
  17. if(e==2)j=4;
  18. if(e==3)j=8;
  19. long long int s=((j%10)*(q))%10;
  20. s=(s-(b+c)%10 +10)%10;
  21. s+=(b+c);
  22. if(s%3==0)
  23. cout<<"YES"<<endl;
  24. else
  25. cout<<"NO"<<endl;
  26. }
  27. else
  28. {
  29. if((b+c)%3==0)
  30. cout<<"YES"<<endl;
  31. else
  32. cout<<"NO"<<endl;
  33.  
  34. }
  35. }
  36. return 0;
  37. }
Success #stdin #stdout 0s 15240KB
stdin
3
5 3 4
13 8 1
760399384224 5 1
stdout
NO
YES
NO