-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchapd.c
61 lines (56 loc) · 853 Bytes
/
chapd.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include<stdio.h>
typedef long long ll;
int a[10000100]={0},pr[1000010];
ll power(ll a,int b)
{
ll res=1;
while(b>0)
res*=a,b--;
return res;
}
int main()
{
int t,i,j,flag=0,count=0;
ll n1,n2,temp,pro;
a[0]=a[1]=1;
for(i=2;i*i<=10000000;i++)
{
if(a[i]==0)
{
for(j=i*i;j<=10000000;j+=i)
a[j]=1;
}
}
j=0;
for(i=2;i<=10000000;i++)
if(a[i]==0)
pr[j++]=i;
scanf("%d",&t);
while(t--)
{
scanf("%lld%lld",&n1,&n2);
flag=0; pro=1;
for(i=0;i<j&&pr[i]<=(n2/2);i++)
{
count=0;
if(n2%pr[i]==0)
{
temp=n2;
//while(temp%pr[i]==0)
//temp/=pr[i],count++;
// pro*=power(pr[i],count);
if(n1%pr[i]!=0){
flag=1;
break;
}
}
}
if(flag==1)
printf("NO\n");
else
{
printf("YES\n");
}
}
return 0;
}