HELP ME IN SOLVING F. Hopping Between Lily Pads (GYM PROBLEM)

Revision en2, by noob_is_my_name, 2021-02-15 14:40:30

Problem link :- https://mirror.codeforces.com/gym/102948/problem/F

I am new to problem solving and was solving this problem, kindly help me with this :- My approach :- we can reach any lily pad which can be expressed in the form of x*N — y*M, x>= 0 && y>=0. So, I am using two loops to do so :-

for(ll i = 0; i<= l; i+= n) {

for(ll j = 0; (i + j) > 0 ;j-= m) {
       if(mp[i + j] == 1){
           mp[i + j] = 0;
           c++;
       }
   }

}

But, it is giving WA, since there was no editorial and I was unable to see other users submission, hence I am writing this blog.

Tags #helpinghands, #help, #guide

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English noob_is_my_name 2021-02-15 14:40:30 9 Tiny change: ' i+= n){\n f' -> ' i+= n){\n\n\n f'
en1 English noob_is_my_name 2021-02-15 14:37:49 702 Initial revision (published)