結果

問題 No.1140 EXPotentiaLLL!
ユーザー face4
提出日時 2020-08-07 09:19:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,289 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 679 ms
コンパイル使用メモリ 64,512 KB
実行使用メモリ 8,632 KB
最終ジャッジ日時 2024-09-22 17:35:00
合計ジャッジ時間 12,719 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

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