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.








Something it's missing is this case 3 2 8 1 7
It can also be solved using the fact that it is always possible to reach some index
iif theiis divisible bygcd(n, m).Solution
Your and my solutions get different results on this case 7 8 8 8 1 2 3 4 5 6 7 8