結果

問題 No.1140 EXPotentiaLLL!
ユーザー nok0nok0
提出日時 2020-07-26 21:09:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,219 ms / 2,000 ms
コード長 407 bytes
コンパイル時間 2,238 ms
コンパイル使用メモリ 200,496 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-11 05:11:59
合計ジャッジ時間 13,501 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,219 ms
4,380 KB
testcase_01 AC 1,207 ms
4,384 KB
testcase_02 AC 1,209 ms
4,380 KB
testcase_03 AC 893 ms
4,380 KB
testcase_04 AC 676 ms
4,380 KB
testcase_05 AC 1,062 ms
4,384 KB
testcase_06 AC 1,022 ms
4,380 KB
testcase_07 AC 1,194 ms
4,388 KB
testcase_08 AC 34 ms
4,384 KB
testcase_09 AC 34 ms
4,380 KB
testcase_10 AC 34 ms
4,384 KB
testcase_11 AC 34 ms
4,380 KB
testcase_12 AC 34 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

vector<bool> ip(5000010, true);

void mt(){
    ip[0] = ip[1] = 0;
    for(int i = 2; i <= 5000000; i++) if(ip[i]) for(int j = 2 * i; j <= 5000000; j += i) ip[j] = false;
}

int main(){
    mt();
    ll n, a, p; cin >> n;
    while(cin >> a >> p){
        if(!ip[p]) cout << -1 << endl;
        else cout << (a % p ? 1 : 0) << endl;
    }
}
0