Help in MULTHREE Problem

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;
}

I think there is problem in your logic you should think about it once again.
You can get help from there MULTHREE - Editorial

can you format your code ? consider using ``` before you start pasting your code, it will do the job

Check out as In every number formation ,either first 4 digits starting from either 2nd or 3rd digit (I didn’t remember exactly) of whole number , the pattern will be repetitive and hence if the number of digits doesn’t end up with a multiple of 4 , then checkout how many you can make (groups of 4 digit) and remaining digits will be first wanted digits from the 4 digits you formed/got while checking the sequence…and at last don’t forget to add first 2-3 digits after which sequence/repetitive is started,and then calculate total sum and check multiple of 3 .