結果

問題 No.1140 EXPotentiaLLL!
ユーザー face4face4
提出日時 2020-08-07 09:19:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,250 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 64,080 KB
実行使用メモリ 8,648 KB
最終ジャッジ日時 2023-10-24 00:32:03
合計ジャッジ時間 12,305 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,250 ms
8,648 KB
testcase_01 AC 1,246 ms
8,648 KB
testcase_02 AC 1,249 ms
8,648 KB
testcase_03 AC 927 ms
8,648 KB
testcase_04 AC 712 ms
8,648 KB
testcase_05 AC 1,125 ms
8,648 KB
testcase_06 AC 1,069 ms
8,648 KB
testcase_07 AC 1,240 ms
8,648 KB
testcase_08 AC 38 ms
8,648 KB
testcase_09 AC 38 ms
8,648 KB
testcase_10 AC 37 ms
8,648 KB
testcase_11 AC 38 ms
8,648 KB
testcase_12 AC 37 ms
8,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

typedef long long ll;
bool nonp[5000001] = {};

int main(){
    nonp[1] = true;
    for(int i = 2; i < 5000001; i++){
        if(nonp[i]) continue;
        for(int j = i+i; j < 5000001; j += i){
            nonp[j] = true;
        }
    }
    int t;
    scanf("%d", &t);
    ll a;
    int p;
    while(t-- > 0){
        cin >> a >> p;
        cout << (nonp[p] ? -1 : a%p==0 ? 0 : 1) << endl;
    }
    return 0;
}

0