結果

問題 No.2682 Visible Divisible
ユーザー daiotadaiota
提出日時 2024-03-20 23:19:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 652 bytes
コンパイル時間 3,060 ms
コンパイル使用メモリ 172,776 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-20 23:19:20
合計ジャッジ時間 5,514 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 167 ms
6,548 KB
testcase_01 AC 176 ms
6,548 KB
testcase_02 AC 170 ms
6,548 KB
testcase_03 AC 167 ms
6,548 KB
testcase_04 AC 60 ms
6,548 KB
testcase_05 AC 61 ms
6,548 KB
testcase_06 AC 62 ms
6,548 KB
testcase_07 AC 162 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 161 ms
6,548 KB
testcase_14 WA -
testcase_15 AC 163 ms
6,548 KB
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i=0;i<int(n);i++)




ll gcd(ll a,ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}


ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}



int main(){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
    int i,j,k;


    int N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N);
    for(i=0;i<N;i++){
    	cin >> A[i];
    	A[i]%=K;
    }

    sort(A.begin(),A.end());

    ll x=1;
    for(i=0;i<N;i++){
    	x=lcm(x,A[i]);
    	x%=K;
    }



    if(x%K==0) cout << "Yes" << endl;
    else cout << "No" << endl;




	return 0;

}
0