結果

問題 No.1140 EXPotentiaLLL!
ユーザー finefine
提出日時 2020-07-31 21:38:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 276 ms / 2,000 ms
コード長 718 bytes
コンパイル時間 1,468 ms
コンパイル使用メモリ 166,420 KB
実行使用メモリ 22,688 KB
最終ジャッジ日時 2023-09-20 22:10:34
合計ジャッジ時間 6,073 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 263 ms
22,520 KB
testcase_01 AC 257 ms
22,492 KB
testcase_02 AC 249 ms
22,688 KB
testcase_03 AC 210 ms
22,456 KB
testcase_04 AC 189 ms
22,460 KB
testcase_05 AC 253 ms
22,524 KB
testcase_06 AC 238 ms
22,572 KB
testcase_07 AC 276 ms
22,372 KB
testcase_08 AC 67 ms
22,568 KB
testcase_09 AC 65 ms
22,568 KB
testcase_10 AC 69 ms
22,584 KB
testcase_11 AC 66 ms
22,556 KB
testcase_12 AC 69 ms
22,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

constexpr char newl = '\n';

template<typename T>
vector<int> sieve(T n) {
    vector<int> is_prime(n + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for (T i = 2; i <= n; i++) {
        if (!is_prime[i]) continue;
        // res.emplace_back(i);
        for (T j = 2 * i; j <= n; j += i) is_prime[j] = false;
    }
    return is_prime;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    auto isp = sieve(5000000);

    int t;
    cin >> t;

    for (int i = 0; i < t; i++) {
        ll a;
        int p;
        cin >> a >> p;
        cout << (isp[p] ? (a % p != 0) : -1) << newl;
    }

    return 0;
}
0