結果

問題 No.1140 EXPotentiaLLL!
ユーザー nok0nok0
提出日時 2020-07-26 20:15:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 213 ms / 2,000 ms
コード長 645 bytes
コンパイル時間 2,073 ms
コンパイル使用メモリ 201,344 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-28 19:34:33
合計ジャッジ時間 5,736 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 206 ms
5,248 KB
testcase_01 AC 200 ms
5,376 KB
testcase_02 AC 213 ms
5,376 KB
testcase_03 AC 147 ms
5,376 KB
testcase_04 AC 123 ms
5,376 KB
testcase_05 AC 178 ms
5,376 KB
testcase_06 AC 169 ms
5,376 KB
testcase_07 AC 206 ms
5,376 KB
testcase_08 AC 39 ms
5,376 KB
testcase_09 AC 40 ms
5,376 KB
testcase_10 AC 41 ms
5,376 KB
testcase_11 AC 41 ms
5,376 KB
testcase_12 AC 39 ms
5,376 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();
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
    int n;
    cin >> n;
    REP(i, n){
        ll a;
        int p;
        cin >> a >> p;
        if(!isprime[p]) cout << -1 << '\n';
        else cout << (a % p ? 1 : 0) << '\n';
    }
}
0