結果

問題 No.1140 EXPotentiaLLL!
ユーザー betrue12betrue12
提出日時 2020-07-31 21:32:13
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,206 ms / 2,000 ms
コード長 510 bytes
コンパイル時間 2,656 ms
コンパイル使用メモリ 199,184 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 21:53:03
合計ジャッジ時間 13,217 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,206 ms
4,380 KB
testcase_01 AC 1,189 ms
4,380 KB
testcase_02 AC 1,203 ms
4,376 KB
testcase_03 AC 873 ms
4,376 KB
testcase_04 AC 669 ms
4,376 KB
testcase_05 AC 1,059 ms
4,380 KB
testcase_06 AC 1,005 ms
4,380 KB
testcase_07 AC 1,157 ms
4,380 KB
testcase_08 AC 39 ms
4,380 KB
testcase_09 AC 39 ms
4,380 KB
testcase_10 AC 39 ms
4,380 KB
testcase_11 AC 39 ms
4,380 KB
testcase_12 AC 39 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int T;
    cin >> T;
    vector<bool> is_prime(5e6+1);
    for(int i=2; i<=5e6; i++) is_prime[i] = true;
    for(int i=2; i<=5e6; i++){
        if(is_prime[i]){
            for(int j=2*i; j<=5e6; j+=i) is_prime[j] = false;
        }
    }
    while(T--){
        int64_t A, P;
        cin >> A >> P;
        if(is_prime[P]){
            cout << (A%P ? 1 : 0) << endl;
        }else{
            cout << -1 << endl;
        }
    }
    return 0;
}
0