結果

問題 No.1140 EXPotentiaLLL!
ユーザー zuminzumin
提出日時 2021-03-25 22:20:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,182 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 716 ms
コンパイル使用メモリ 70,164 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-05 11:13:06
合計ジャッジ時間 11,504 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,182 ms
6,816 KB
testcase_01 AC 1,122 ms
6,940 KB
testcase_02 AC 1,121 ms
6,940 KB
testcase_03 AC 793 ms
6,940 KB
testcase_04 AC 630 ms
6,944 KB
testcase_05 AC 987 ms
6,940 KB
testcase_06 AC 906 ms
6,940 KB
testcase_07 AC 1,090 ms
6,944 KB
testcase_08 AC 37 ms
6,940 KB
testcase_09 AC 37 ms
6,944 KB
testcase_10 AC 36 ms
6,944 KB
testcase_11 AC 38 ms
6,944 KB
testcase_12 AC 36 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

int main(){
    int t;
    cin>>t;
    vector<bool> prime(10010010,true);
    prime[0]=false;
    prime[1]=false;

    for(int i=2;i*i<=10010010;i++){
        if(!prime[i]) continue;
        for(int j=i*i;j<=10010010;j+=i){
            prime[j]=false;
        }
    }
    for(int i=0;i<t;i++){
        long long a,p;
        cin>>a>>p;
        if(!prime[p]){
            cout<<-1<<endl;
            continue;
        }
        if(a%p==0){
            cout<<0<<endl;
        }else{
            cout<<1<<endl;
        }

    }
    return 0;
}
0