結果

問題 No.1140 EXPotentiaLLL!
ユーザー tsugutsugutsugutsugu
提出日時 2020-08-01 20:32:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,249 ms / 2,000 ms
コード長 825 bytes
コンパイル時間 1,392 ms
コンパイル使用メモリ 166,068 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 14:40:48
合計ジャッジ時間 14,914 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,240 ms
4,376 KB
testcase_01 AC 1,225 ms
4,376 KB
testcase_02 AC 1,249 ms
4,380 KB
testcase_03 AC 899 ms
4,376 KB
testcase_04 AC 689 ms
4,380 KB
testcase_05 AC 1,089 ms
4,376 KB
testcase_06 AC 1,046 ms
4,376 KB
testcase_07 AC 1,212 ms
4,376 KB
testcase_08 AC 35 ms
4,380 KB
testcase_09 AC 35 ms
4,376 KB
testcase_10 AC 35 ms
4,380 KB
testcase_11 AC 35 ms
4,380 KB
testcase_12 AC 35 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

struct Sieve {
    vector<bool> isprime;
    int n;
    Sieve(int n_) : isprime(n_ + 1, true), n(n_) {};
    void build() {
        isprime[0] = isprime[1] = false;
        for(int i = 2; i <= n; i++) {
            if(isprime[i]) {
                for(int j = i + i; j <= n; j += i) {
                    isprime[j] = false;
                }
            }
        }
    }
    bool isp(int i) {
        return isprime[i];
    }
};

const int mxN = 5e6;

int main() {
    Sieve P(mxN);
    P.build();
    int t;
    cin >> t;
    while(t--) {
        ll a; int p;
        cin >> a >> p;
        if(!P.isp(p)) {
            printf("%d\n", -1);
        }else{
            if(a % p == 0) printf("%d\n", 0);
            else printf("%d\n", 1);
        }
    }
}
0