Codeforces and Polygon may be unavailable from May 23, 4:00 (UTC) to May 23, 7:00 (UTC) due to technical maintenance. ×

Please_Read's blog

By Please_Read, history, 22 months ago, In English

Official problem and code link : https://codeforces.com/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?