0w1

CFR 688 D. Remainders Game ( Chinese Remainder Theorem )

Problem - D - Codeforces
According to the CRT, we have the conclusion that
x % M = resolute value,
if all values x % m[ i ] are known, where m[ i ] are all co-prime, and PRODUCT( m[ * ] ) = M.
It is obvious that knowing x % p, where p % q == 0, we will know x % ( p / q ) as well.
So we will know the value of x % LCM( m[ * ] ).
And now, if LCM( m[ * ] ) is a multiple of M, we will assure the the exact value of x % M.
In a nutshell, we will only have to know whether LCM( C[ * ] ) % K == 0 or not.

void solve(){
    int N, K; cin >> N >> K;
    vi C( N );
    for( int i = 0; i < N; ++i )
        cin >> C[ i ];
    int lcm = 1;
    for( int i = 0; i < N; ++i )
        lcm = 1LL * C[ i ] / __gcd( lcm, C[ i ] ) * lcm % K;
    if( lcm == 0 ) cout << "Yes\n";
    else cout << "No\n";
}