Main topic:
Given two numbers, n,m, find if all factorization of M can be n, the whole word output "Yes", OR "No".
Text
3120 75128 167 8Output:yesyesno
Until the greatest common divisor is 1, see if the latter is 1.
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include < cmath> #include <math.h> #include <queue> #define INF 0x3f3f3f3fusing namespace Std;long long gcd (Long long N,long long m) { return m==0?n:gcd (m,n%m);//forgot to add return wa several times. }int Main () { long long n,m,cla; cin>>cla; while (cla--) { cin>>n>>m; Long Long K=GCD (n,m); while (k>1) { m=m/k; K=GCD (n,m); } if (m==1) cout<< "Yes" <<endl; else cout<< "No" <<endl; } return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Chef and Prime divisors problem CODE:CHAPD (gcd problem)