HDU1222
思路:思路:m和n如果有公约数,则安全洞存在,无公约数或公约数为1,则无


1 # include
2 typedef long long LL;
3
4 LL gcd(LL m, LL n)
5 {
6 if(m<n)
7 {
8 int t &#61; m;
9 m &#61; n;
10 n &#61; t;
11 }
12 while (n !&#61; 0)
13 {
14 int r &#61; m % n;
15 m &#61; n;
16 n &#61; r;
17 }
18 return m;
19 }
20
21 void run()
22 {
23 int p, n, m;
24 scanf("%d", &p);
25 while(p--)
26 {
27 scanf("%d%d", &m, &n);
28 if(m &#61;&#61; 1)
29 {
30 printf("NO\n");
31 }
32 else if(gcd(m, n) &#61;&#61; 1)
33 {
34 printf("NO\n");
35 }
36 else
37 {
38 printf("YES\n");
39 }
40 }
41 }
42
43 int main(void)
44 {
45 run();
46
47 return 0;
48 }
PS: a和b最小公倍数&#xff1a;a * b / gcd&#xff08;a&#xff0c; b&#xff09;