Files
python/TangDou/LuoGuBook/P2651.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

29 lines
673 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
int t;
//最大公约数
int gcd(int x, int y) {
return y ? gcd(y, x % y) : x;
}
int main() {
cin >> t;
while (t--) {
int n;
cin >> n;
//一次读入第一个和第二个
int a, b;
cin >> a >> b;
b /= gcd(a, b);//去掉a,b公因子目标是b=1,a已经发近挥不出来力量啦
//逐个读入,逐个约分
for (int i = 3; i <= n; i++) {
int x;
cin >> x;
b /= gcd(x, b);
}
if (b == 1) cout << "Yes" << endl;
else cout << "No" << endl;
}
return 0;
}