結果

問題 No.1140 EXPotentiaLLL!
ユーザー nok0nok0
提出日時 2020-07-26 19:50:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,226 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 2,021 ms
コンパイル使用メモリ 200,304 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-11 05:11:25
合計ジャッジ時間 13,704 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,226 ms
4,380 KB
testcase_01 AC 1,215 ms
4,376 KB
testcase_02 AC 1,221 ms
4,376 KB
testcase_03 AC 883 ms
4,380 KB
testcase_04 AC 679 ms
4,380 KB
testcase_05 AC 1,077 ms
4,380 KB
testcase_06 AC 1,012 ms
4,380 KB
testcase_07 AC 1,196 ms
4,380 KB
testcase_08 AC 45 ms
4,380 KB
testcase_09 AC 44 ms
4,380 KB
testcase_10 AC 44 ms
4,380 KB
testcase_11 AC 44 ms
4,380 KB
testcase_12 AC 45 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)

vector<bool> isprime(5000010, false);

void make_table(){
    for(int i = 2; i <= 5000000; i++) isprime[i] = true;
    for(int i = 2; i <= 5000000; i++) if(isprime[i]) for(int j = 2 * i; j <= 5000000; j += i) isprime[j] = false;
}

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