結果

問題 No.1140 EXPotentiaLLL!
ユーザー boutarouboutarou
提出日時 2020-08-02 12:48:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 728 bytes
コンパイル時間 1,682 ms
コンパイル使用メモリ 170,308 KB
実行使用メモリ 9,780 KB
最終ジャッジ日時 2023-09-25 14:32:09
合計ジャッジ時間 13,979 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,154 ms
9,520 KB
testcase_01 AC 1,177 ms
9,588 KB
testcase_02 WA -
testcase_03 AC 856 ms
8,320 KB
testcase_04 AC 659 ms
7,336 KB
testcase_05 AC 1,041 ms
9,428 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
*    author:  boutarou
*    created: 02.08.2020 12:43:46
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
    int t;
    cin >> t;
    vector<ll> a(t);
    vector<int> p(t);
    int max_p = 1;
    rep(i, t) cin >> a[i] >> p[i];
    rep(i, t) max_p = max(max_p, p[i]);
    vector<bool> check(max_p + 1, false);
    check[1] = true;
    for (int i = 2; i <= max_p; i++) {
        if (check[i]) continue;
        for(int j = 2 * i; j <= max_p; j += i) {
            check[j] = true;
        }
    }
    rep(i, t) {
        if (!check[p[i]]) cout << 1 << endl;
        else cout << -1 << endl;
    }
    return 0;
}
0