In this question, in the last example test case given, we have **k=760399384224,d0=5, and d1=1**. Now we know that a number is multiple of 3 if the sum of it’s digits is a multiple of 3. So applying it here, we separate the number n into 3 parts,

Part 1: First 3 digits -> 516 , (5+1+6) mod 3 ==0, so rem1 = 0.

Part 2: Next will be (k-3)/4 times repetition of (2486) ,or,rem2 = ((2+4+8+6)*((k-3)/4))%3= 1

Part 3: the last (k-3)%4 =1 digits which will be 2 (from 2486 repetition) , so rem3 = 2%3=2

So the final answer should be (rem1+rem2+rem3)%3

and I wrote the following code for this logic:

```
#include<iostream>
```

#define ll long long

using namespace std;

int main()

{

int t;

cin>>t;

while(t–)

{

ll k;

cin>>k;

int d0,d1;

cin>>d0>>d1;

int d2 = (d0+d1)%10;

int d[4];

d[0] = (d0+d1+d2)%10;

d[1] = (2*d[0])%10;
d[2] = (2*d[1])%10;

d[3] = (2

*d[2])%10;*

ll rem1 = (d0+d1+d2)%3,rem2,rem3=0;

rem2 = (20(((k-3)/4)%3))%3;

ll rem1 = (d0+d1+d2)%3,rem2,rem3=0;

rem2 = (20

ll x = (k-3)%4;

if(x!=0)

{

for(int i=0; i<x; ++i)

rem3+=d[i];

rem3 = rem3%3;

}

else

rem3 =0;

if(k==3)

{

rem2=0;

rem3=0;

}

else if(k==2)

{

rem1 = (d0+d1)%3;

rem2=0;

rem3=0;

}

if((rem1+rem2+rem3)%3==0)

cout<<“YES”<<endl;

else

cout<<“NO”<<endl;

}

}

Now they’re giving me WA in their test cases. And I cant think of a possible test cases which doesn’t work with this code. So somebody help me out please.