結果

問題 No.1140 EXPotentiaLLL!
ユーザー onsen_manjuuu
提出日時 2020-08-01 00:56:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 573 bytes
コンパイル時間 1,590 ms
コンパイル使用メモリ 169,212 KB
実行使用メモリ 13,024 KB
最終ジャッジ日時 2024-07-06 23:15:34
合計ジャッジ時間 10,937 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long;

int MAX = 1e7;
vector<char> prime(MAX+1);
void f() {
    for(int i = 2; i <= MAX; i++) {
        if(prime[i])continue;
        for(int j = i + i; j <= MAX; j += i)prime[j] = true;
    }
}


void solve() {

    ll a, p;
    cin >> a >> p;
    if(prime[p]) {
        cout << -1 << endl;
    }
    else if(a % p == 0) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}

int main()
{
    cin.tie(0);ios::sync_with_stdio(0);
    f();
    int T;
    cin >> T;
    while(T--)solve();
}
0