Please_Read's blog

By Please_Read, history, 2 years ago, In English

Official problem and code link : https://codeforces.me/blog/entry/91195

in the solution of problem B (1526B — I Hate 1111), the author only run the loop for 20 times, how it is guaranteed that the answer will be found within 20 iterations?

because if x is too large, like 10e8, after 20 iterations it will still remain tense to 1e8

please help me to understand this

i am taking about this loop :

rep(x,0,20){
       if (n%11==0){
         cout<<"YES"<<endl;
         goto done;
       }

       n-=111;
       if (n<0) break;
    }
  • Vote: I like it
  • -12
  • Vote: I do not like it

| Write comment?