Hi, kindly help to find why this code is failing. It is working on sample test case and the logic also is same as the one used by others still when I submit it gives wrong answer. I am not able to find for which test case my code is giving wrong answer. Kindly someone help me in this.
Thanks
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
int main() {
// your code goes here
long long int t;
cin>>t;
int d0, d1;
long long int sum, k;
long long int ng, nr;
long long int sum_nr;
while(t--){
sum = 0;
cin>>k>>d0>>d1;
sum_nr = (d0+d1)%10;
if(k == 2){
if((d0+d1)%3 == 0){
cout<<"YES";
}
else{
cout<<"NO";
}
}
else{
// pattern repeat with every 4 element
ng = (k-3)/4;
nr = (k-3)%4;
for( long long int i=0;i<nr;i++){
sum_nr = (2*sum_nr)%10;
sum+=sum_nr;
}
sum+=(d0 + d1 + (d0 + d1)%10 + ng*20);
// cout<<sum;
if(sum%3==0){
cout<<"YES";
}
else{
cout<<"NO";
}
}
cout<<"\n";
}
return 0;
}