結果

問題 No.1140 EXPotentiaLLL!
ユーザー Manuel1024Manuel1024
提出日時 2021-03-30 02:52:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 558 bytes
コンパイル時間 632 ms
コンパイル使用メモリ 69,724 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-07 07:47:49
合計ジャッジ時間 13,775 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,243 ms
5,248 KB
testcase_01 AC 1,265 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 908 ms
5,376 KB
testcase_04 AC 687 ms
5,376 KB
testcase_05 AC 1,089 ms
5,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 36 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 36 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
using ll = long long int;
constexpr int TABLEMAX = 5000010;

int main(){
    vector<bool> isprime(TABLEMAX, true);
    isprime[0] = isprime[1] = false;
    for(int i = 2; i < TABLEMAX; i++){
        if(!isprime[i]) continue;
        for(int j = 2; i*j < TABLEMAX; j++) isprime[i*j] = false;
    }

    int t;
    cin >> t;
    while(t--){
        ll a, p;
        cin >> a >> p;
        if(!isprime[p]) cout << -1 << endl;
        else{
            cout << 1 << endl;
        }
    }
    return 0;
}
0