結果

問題 No.1140 EXPotentiaLLL!
ユーザー Sooh31
提出日時 2020-08-19 11:52:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,601 ms / 2,000 ms
コード長 746 bytes
コンパイル時間 3,215 ms
コンパイル使用メモリ 191,868 KB
最終ジャッジ日時 2025-01-13 03:44:03
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const ll mod = 1000000007;
const int INF = 1001001001;

bool is_prime[10000000];

void init(){
    for(int i = 0; i < 6000000; i++){
        is_prime[i] = true;
    }
    for(int i = 2; i < 6000000; i++){
        if(!is_prime[i]) continue;
        for(int j = 2; i*j < 6000000; j++){
            is_prime[i*j] = false;
        }
    }
}

int main(){
    int t; cin >> t;
    init();
    is_prime[0] = is_prime[1] = false;
    while(t--){
        ll a, p; cin >> a >> p;
        if(!is_prime[p]){
            cout << -1 << endl;
            continue;
        }
        if(a % p == 0) cout << 0 << endl;
        else cout << 1 << endl;

    }
}
0