【题目分析】
每次用gcd去约分。或者唯一分解定理
【代码】
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int a,b;
inline int gcd(int a,int b)
{
return (b==0)?a:gcd(b,a%b);
}
int main()
{
int tt;
scanf("%d",&tt);
while (tt--)
{
scanf("%d",&a);getchar();
scanf("%d",&b);
b/=gcd(a,b);
while (getchar()!='\n')
{
scanf("%d",&a);
b/=gcd(a,b);
}
if (b==1) printf("YES\n");
else printf("NO\n");
}
}