結果

問題 No.1140 EXPotentiaLLL!
ユーザー finefine
提出日時 2020-07-31 21:36:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 707 bytes
コンパイル時間 2,060 ms
コンパイル使用メモリ 165,812 KB
実行使用メモリ 22,700 KB
最終ジャッジ日時 2023-09-20 22:07:22
合計ジャッジ時間 6,520 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 256 ms
22,460 KB
testcase_01 AC 262 ms
22,448 KB
testcase_02 WA -
testcase_03 AC 229 ms
22,700 KB
testcase_04 AC 203 ms
22,684 KB
testcase_05 AC 262 ms
22,560 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 87 ms
22,420 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 83 ms
22,660 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] ? 1 : -1) << newl;
    }

    return 0;
}
0