結果

問題 No.1140 EXPotentiaLLL!
ユーザー chielochielo
提出日時 2020-07-31 21:32:56
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 641 bytes
コンパイル時間 1,364 ms
コンパイル使用メモリ 164,024 KB
実行使用メモリ 18,036 KB
最終ジャッジ日時 2023-09-20 21:56:09
合計ジャッジ時間 5,963 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 244 ms
17,828 KB
testcase_01 AC 239 ms
17,756 KB
testcase_02 AC 249 ms
17,832 KB
testcase_03 AC 207 ms
17,868 KB
testcase_04 AC 176 ms
17,844 KB
testcase_05 AC 236 ms
17,756 KB
testcase_06 AC 222 ms
17,908 KB
testcase_07 AC 260 ms
18,036 KB
testcase_08 AC 84 ms
17,756 KB
testcase_09 AC 84 ms
17,756 KB
testcase_10 AC 84 ms
17,744 KB
testcase_11 AC 84 ms
17,744 KB
testcase_12 AC 85 ms
17,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

const int maxp = 1e7 + 3;

int p[maxp], pl;
bool isc[maxp];

int main() {
    for(int i = 2; i < maxp; ++i) {
        if(!isc[i])
            p[pl++] = i;
        for(int j = 0; j < pl && i * (long long)p[j] < maxp; ++j) {
            isc[i * p[j]] = true;
            if(i % p[j] == 0)
                break;
        }
    }
    isc[0] = isc[1] = true;
    int t;
    scanf("%d", &t);
    while(t--) {
        long long a; int p;
        scanf("%lld%d", &a, &p);
        if(isc[p])
            puts("-1");
        else if(a % p != 0)
            puts("1");
        else
            puts("0");
    }
    return 0;
}
0