https://codeforces.com/contest/1538/problem/D
Sir I don’t know where I am going wrong, please tell me how to correct it.
https://codeforces.com/contest/1538/problem/D
Sir I don’t know where I am going wrong, please tell me how to correct it.
You are missing the case that a can be equal to b, and we can have k > 0;
lets say a = 2, b = 2 and k = 2;
So divide your yes condition into two parts when k = 1 and k!=1.
if(__gcd(a,b)==a || __gcd(a,b)==b) m = 1;
else m = 2;
if(a==b) m = 0;
if((k >= m && k <= n && k!=1) || (m==1 && k==1))
{ cout << "YES" << endl;
continue;
}
cout << "NO" << endl;
But now your code will give tle. You need to use spf array to quickly factorise each number,
See this https://www.geeksforgeeks.org/prime-factorization-using-sieve-olog-n-multiple-queries/
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.