結果

問題 No.2682 Visible Divisible
ユーザー HigurashiHigurashi
提出日時 2024-03-20 22:08:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,181 bytes
コンパイル時間 7,898 ms
コンパイル使用メモリ 482,392 KB
実行使用メモリ 23,724 KB
最終ジャッジ日時 2024-03-20 22:08:40
合計ジャッジ時間 14,923 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が10進数で1024桁の浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

// ユークリッドの互除法
Bint gcd(Bint a, Bint b)
{
    if (a % b == 0)
    {
        return b;
    }
    else
    {
        return gcd(b, a % b);
    }
}

int main()
{
    long long n, k;
    cin >> n >> k;

    vector<Bint> a(n);
    for (auto &in : a)
    {
        cin >> in;
    }
    Bint aGcd = a[0];
    for (int i = 1; i < n; i++)
    {
        aGcd = gcd(aGcd, a[i]);
    }

    for (auto &elem : a)
    {
        elem /= aGcd;
    }

    Bint aLcm = a[0];
    for (int i = 1; i < n; i++)
    {
        aLcm *= a[i];
    }

    if (aLcm % k == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}
0