XTU1199:Number Game

2014-11-24 13:06:03 · 作者: · 浏览: 0

题目描述

给你一个有N个数的集合S和一个数X,判断是否存在S的一个子集,子集里的数的最小公倍数正好是X。

输入

第一行是数据组数T。 接下来有多组数据,每组数据包含两行: 第一行有2个数N和X,1<=N<=100000 ,X<=10^9。 第二行给出N个数,1<=S[i]<=10^9。

输出

对于每一组数据,输出一行"Case #X: Y",X是第几组数据,Y是Yes或No。

样例输入

2
4 20
2 3 4 5
3 61
3 4 5

样例输出

Case #1: Yes
Case #2: No
 
 
#include 
   
    
#include 
    
      #include 
     
       using namespace std; #define ll __int64 ll a[100005],p[100005],len; ll gcd(ll a,ll b) { if(b) return gcd(b,a%b); else return a; } int main() { ll t,n,x,i,j,r,cas = 1,sum; scanf("%I64d",&t); while(t--) { scanf("%I64d%I64d",&n,&x); sum = 1; for(i = 0; i