結果
| 問題 | 
                            No.1140 EXPotentiaLLL!
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Sooh31
                         | 
                    
| 提出日時 | 2020-08-19 11:50:05 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 707 bytes | 
| コンパイル時間 | 2,048 ms | 
| コンパイル使用メモリ | 191,732 KB | 
| 最終ジャッジ日時 | 2025-01-13 03:43:41 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 9 WA * 3 | 
ソースコード
#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();
    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;
    }
}
            
            
            
        
            
Sooh31