結果

問題 No.1140 EXPotentiaLLL!
ユーザー ks115ks115
提出日時 2021-11-21 16:42:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,211 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 3,555 ms
コンパイル使用メモリ 199,932 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 02:19:43
合計ジャッジ時間 14,378 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,211 ms
4,376 KB
testcase_01 AC 1,202 ms
4,376 KB
testcase_02 AC 1,195 ms
4,380 KB
testcase_03 AC 857 ms
4,380 KB
testcase_04 AC 656 ms
4,376 KB
testcase_05 AC 1,055 ms
4,376 KB
testcase_06 AC 991 ms
4,380 KB
testcase_07 AC 1,179 ms
4,380 KB
testcase_08 AC 18 ms
4,376 KB
testcase_09 AC 18 ms
4,376 KB
testcase_10 AC 18 ms
4,380 KB
testcase_11 AC 18 ms
4,380 KB
testcase_12 AC 19 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

const int N = 5e6;
vector<bool> primes(N + 1, true);
void init() {
    primes[0] = primes[1] = false;
    for (int i = 2; i * i <= N; i++) {
        if (!primes[i]) continue;
        for (int j = 2 * i; j <= N; j += i) primes[j] = false;
    }
}

int main() {
    init();

    int T; cin >> T;
    while (T--) {
        ll A; int P; cin >> A >> P;
        if (primes[P]) {
            cout << (A % P == 0 ? 0 : 1) << endl;
        } else {
            cout << -1 << endl;
        }
    } 
    return 0;
}
0