why I am getting TLE in O(1) solution

Question Link : CodeChef: Practical coding for everyone

```
#include<bits/stdc++.h>
#define ull long long int
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
ull k,d0,d1,sum,count=2;
cin>>k>>d0>>d1;
sum=d0+d1;
if(k>2)
{
while((sum%10)!=8&&count!=k)
{
sum+=sum%10;
count++;
}
count=k-count;
sum+=20*(count/4);
count=count%4;
if(count==1)
sum+=8;
else if(count==2)
sum+=14;
else if(count==3)
sum+=16;
}
if(sum%3==0)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}
```