結果

問題 No.1140 EXPotentiaLLL!
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2020-07-31 23:07:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,005 bytes
コンパイル時間 1,922 ms
コンパイル使用メモリ 151,720 KB
実行使用メモリ 6,028 KB
最終ジャッジ日時 2023-09-21 02:12:49
合計ジャッジ時間 12,597 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,209 ms
5,788 KB
testcase_01 AC 1,206 ms
5,636 KB
testcase_02 WA -
testcase_03 AC 866 ms
5,704 KB
testcase_04 AC 687 ms
5,844 KB
testcase_05 AC 1,040 ms
5,636 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 35 ms
5,840 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 36 ms
5,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.07.31 23:07:32
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;



struct Eratosthenes {
private:
    int N;
public:
    std::vector< bool > isprime;
    std::vector< int > prime;
    Eratosthenes(int n) : N(n) {
        isprime.resize(N + 1, true);
        isprime[0] = isprime[1] = false;
        for (int i = 2; i * i <= N; i++) {
            if (isprime[i]) {
                for (int j = i + i; j <= N; j += i) {
                    isprime[j] = false;
                }
            }
        }
        for (int i = 2; i <= N; i++) {
            if (isprime[i]) {
                prime.push_back(i);
            }
        }
    }
};
int main() {
    int t;cin >> t;
    Eratosthenes era(5 * 1000000);
    while(t--) {
        ll a, p;
        cin >> a >> p;
        if (era.isprime[p]) {
            cout << 1 << endl;
        }
        else {
            cout << -1 << endl;
        }
    }
    return 0;
}
0