結果

問題 No.1140 EXPotentiaLLL!
ユーザー nok0nok0
提出日時 2020-07-27 16:12:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 235 ms / 2,000 ms
コード長 558 bytes
コンパイル時間 2,003 ms
コンパイル使用メモリ 198,224 KB
実行使用メモリ 8,384 KB
最終ジャッジ日時 2023-09-11 05:54:51
合計ジャッジ時間 5,982 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 213 ms
8,300 KB
testcase_01 AC 209 ms
8,224 KB
testcase_02 AC 217 ms
8,312 KB
testcase_03 AC 176 ms
8,308 KB
testcase_04 AC 145 ms
8,284 KB
testcase_05 AC 204 ms
8,256 KB
testcase_06 AC 197 ms
8,384 KB
testcase_07 AC 235 ms
8,264 KB
testcase_08 AC 38 ms
8,292 KB
testcase_09 AC 39 ms
8,360 KB
testcase_10 AC 38 ms
8,220 KB
testcase_11 AC 38 ms
8,208 KB
testcase_12 AC 38 ms
8,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

bool isprime[5000010];

void eratosthenes(){
    isprime[0] = isprime[1] = false;
    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(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    eratosthenes();
    ll n, a, p; cin >> n;
    while(cin >> a >> p){
        if(isprime[p]) cout << (a % p ? 1 : 0) << '\n';
        else cout << -1 << '\n';
    }
}
0