Multiple of 3

what is wrong with this approach?.i am getting runtime error but my sample test case is passing.
#include
using namespace std;

int main() {
int t;
cin>>t;
while(t–)
{
long long int k;
int d0,d1;
cin>>k>>d0>>d1;
long long int a[k];
a[0]=d0;
a[1]=d1;
long long int sum=d0+d1;
for(int i=2;i<k;i++)
{
a[i]=sum%10;
sum=sum+a[i];
}
long long int div_by_3=0;
for(int i=0;i<k;i++)
{
div_by_3=div_by_3+a[i];
}
if(div_by_3%3==0)
cout<<“YES”<<endl;
else
cout<<“NO”<<endl;
}
return 0;
}


is this the same question?
i have already posted my solution code over there, please check.
(if not, then please add link to your question and then i shall answer)
Hope it helps :+1: :slightly_smiling_face:

1 Like

Sorry, posted the wrong link^^
here, try this one:
https://www.codechef.com/viewsolution/33548418
(Accidentally posted the code in which the doubt had arisen… :flushed: :cry: )

[don’t use the link in first post, you may use the quoted doubt tho]

1 Like

Please format the code , link the problem , etc