D. remainders Game
Today Pari and Arya are playing a game called remainders.
Pari chooses, positive integer x and K , and tells Arya k but not x . Arya has to find the value . There Are n ancient numbers c Span class= "Lower-index" >1, C 2, ..., c N and Pari have to tell Arya if Arya wants. Given K and The ancient values, tell us if Arya have a winning strategy Independe NT of value Of x or not. Formally, is it true this Arya can understand the value for any positive integer x ?
Note, that's means the remainder of x after dividing it by y.
Input
The first line of the input contains the integers n and k (1≤ n, K ≤1 -the number of ancient integers and value k that's chosen by Pari.
The second line contains n integers c1, C2, ..., c n (1≤ ci ≤1).
Output
Print "Yes" (without quotes) if Arya has a winning strategy independent of value of x, or "No" (Witho UT quotes) otherwise.
Examplesinput
4 5
2 3 5 12
Output
Yes
Input
2 7
2 3
Output
No
Note
In the first sample, Arya can understand because 5 is one of the ancient numbers.
In the second sample, Arya can ' t be sure. For example 1 and 7 has the same remainders after dividing by 2 and 3, but they differ in remainders afte R dividing by 7.
#include <cstdio>#include<cmath>#include<cstring>#include<algorithm>#include<map>#include<iostream>using namespacestd;#definell Long Longll LCM;Const intMAXN = 1e6 +Ten; ll GETLCM (ll A, ll b) {returnA/__GCD (A, b) *b;} ll P[MAXN];intMain () {ll n, K; while(~SCANF ("%i64d%i64d", &n, &k)) { for(inti =1; I <= N; i++) scanf ("%i64d", &P[i]); ll LCM=1; intFlag =0; for(inti =1; I <= N; i++) {LCM=GETLCM (LCM, p[i]); LCM= LCM%K; if(LCM = =0) {puts ("Yes"); Flag=1; Break; } } if(!flag) puts ("No"); }}
Codeforces Round #(Div. 2) D. Remainders Game (Chinese remainder theorem)