# MULTHREE efficiency problem(DSA Contest 1)

``````#define ll long long int
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#include <iostream>
#include <bits/stdc++.h>
#include <string>

using namespace std;

int main(){
boost_io;
int t;
cin>>t;
while(t-->0){
ll k, s=0;
cin>>k;
int d0, d1;
cin>>d0>>d1;
if(k==2){
s=d0+d1;
}
else{
int d=(d0+d1)%10;
s+=d0+d1+d;
int h=3;
int ha[4];
ha[0]=0;ha[1]=4;ha[2]=12;ha[3]=18;
for(;h<=k;){
d=(2*d)%10;
if(d!=4){
s+=d;
h++;
}
else{
break;
}
}
s+=((k-h)/4)*20+ha[(k-h)%4];
}
if(s%3==0){
cout<<"YES\n";
}
else{
cout<<"NO\n";
}
}
return 0;
}
``````

Thanks Again.

you could use ha[4]={0,4,12,18} instead of ha[0]=0;ha[1]=4;ha[2]=12;ha[3]=18;
initialize d0 and d1 first. Your code shold be more structured and variable
should be chosen according to the problem.
h=3
for(;h<=k;){
d=(2d)%10;
if(d!=4){
s+=d;
h++;
}
else{
break;
}
}
instead of this use this or more structured
h=3
while(h<=k)
{
d=(2
d)%10;
if (d!=4)
{
s+=d;
h+=1
}
else
{
break;
}
}
Any suggestion from anyother chef is appreciated. Happy Coding

Thanks for all your suggestions will work on it.