P2651 添加括号III
无论怎么添加,a2一定是分母,其他的可以是分子,所以最后看看,(a1*a3*..*an)%a2==0即可
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstring>
#define inf 2147483647
#define For(i,a,b) for(register int i=a;i<=b;i++)
#define p(a) putchar(a)
#define g() getchar()
//by war
//2017.10.19
using namespace std;
int t;
int n;
int x;
int g,gg;
int a1,a2;
bool flag;
void in(int &x)
{
int y=;
char c=g();x=;
while(c<''||c>'')
{
if(c=='-')
y=-;
c=g();
}
while(c<=''&&c>='')x=x*+c-'',c=g();
x*=y;
}
void o(int x)
{
if(x<)
{
p('-');
x=-x;
}
if(x>)o(x/);
p(x%+'');
} int gcd(int a,int b)
{
return (b==?a:gcd(b,a%b));
} int main()
{
in(t);
For(i,,t)
{
flag=false;
in(n);
in(a1),in(a2);
a2/=gcd(a2,a1);
For(j,,n)
{
in(x);
a2/=gcd(a2,x);
}
if(a2==)
puts("Yes");
else
puts("No");
}
return ;
}