Euclid’s lemma
#include <bits/stdc++.h>
using namespace std;
/* If p divides x*y and p is relatively prime to x,
then p must divide y. In the above example,
5 is relatively prime to 6, therefore it must divide 15.
*/
int main()
{
int a,b,ab,p;
cin >> a >> b >> p;
ab = a*b;
if(ab%p == 0){
if(a%p == 0 || b%p == 0)
cout << "YES\n";
else
cout << "NO\n";
}
return 0;
}

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home