MULTHREE problem

Hey, I am doing this MULTHREE problem of DSA learning series week 1. I am writing the code which is giving correct output in other editors. My solution is correct. But I don’t know why the CodeChef editor is not accepting it and it is displaying my solution as “WRONG ANSWER”. Here’s my solution for your convenience.

#include
using namespace std;

int is_Multhree(int k, int d0, int d1)
{
int di;
long sum = d0 + d1;
for(int i = 2; i < k; i++)
{
di = sum % 10;
sum += di;
}
if(sum % 3 == 0)
return 1;
else
return 0;
}

int main() {
// your code goes here
int T, res;
int k, d0, d1;
cin>>T;
for(int i = 0; i < T; i++)
{
cin>>k;
cin>>d0;
cin>>d1;
res = is_Multhree(k, d0, d1);
if(res == 1)
cout<<“YES”<<"\n";
else
cout<<“NO”<<"\n";
}
return 0;
}

you are calculating sum modulus instead you have to calculate the modulus for di formed after iteration is over.