結果

問題 No.1250 汝は倍数なりや?
ユーザー goto_isyuku
提出日時 2020-10-10 01:10:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 851 bytes
コンパイル時間 1,645 ms
コンパイル使用メモリ 169,444 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-07-20 15:11:17
合計ジャッジ時間 4,611 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other TLE * 1 -- * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(X, N) for (ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(), (V).end()
#define endl "\n"

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;

long long gcd(long long a, long long b){
    if (a < b)
        swap(a, b);
    assert(b != 0);
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}

int main(){

    int n, h;
    cin >> n >> h;

    vector<int> a(n);

    rep(i, n) cin >> a[i];
    int oldh = h;

    do{
        oldh = h;

        rep(i, n){
            int g = gcd(a[i], h);
            a[i] = a[i] / g;
            h = h / g;
        }

    }while(oldh != h);

    cout << (oldh == 1 ? "YES" : "NO") << endl;
    
    return 0;
}
0