【codechef】Chef and Prime Divisors(判断A能否被B的所有素因子整除)

#include<iostream>  
#include<algorithm>  
#include<string>  
#include<map>  
#include<vector>  
#include<cmath>  
#include<queue>  
#include<string.h>  
#include<stdlib.h>  
#include<stdio.h>
#define ll long long  
#define mod 1000000007
using namespace std;
ll gcd(ll a,ll b){
        return b?gcd(b,a%b):a;}
int main(){
	int t;
	cin>>t;
	while(t--){
		ll a,b;
		cin>>a>>b;
		int u=0;
		while(gcd(a,b)!=1){
			b/=gcd(a,b); //不断缩小b
			if(b==1)
				break;
		}
		if(b==1)
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
	return 0;
} 


你可能感兴趣的:(【codechef】Chef and Prime Divisors(判断A能否被B的所有素因子整除))