結果

問題 No.1140 EXPotentiaLLL!
ユーザー boutarou
提出日時 2020-08-02 12:56:01
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 912 bytes
コンパイル時間 1,469 ms
コンパイル使用メモリ 173,636 KB
実行使用メモリ 9,856 KB
最終ジャッジ日時 2024-07-18 11:33:25
合計ジャッジ時間 11,980 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 11 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
*    author:  boutarou
*    created: 02.08.2020 12:43:46
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
using ll = long long;
using P = pair<int, int>;

long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a;}

int main() {
    int t;
    cin >> t;
    vector<ll> a(t);
    vector<int> p(t);
    int max_p = 1;
    rep(i, t) cin >> a[i] >> p[i];
    rep(i, t) max_p = max(max_p, p[i]);
    vector<bool> check(max_p + 1, false);
    check[1] = true;
    for (int i = 2; i <= max_p; i++) {
        if (check[i]) continue;
        for(int j = 2 * i; j <= max_p; j += i) {
            check[j] = true;
        }
    }
    rep(i, t) {
        if (!check[p[i]]) {
            if (a[i] % (ll)p[i] == 0 || (ll)p[i] % a[i] == 0) cout << 0 << endl;
            else cout << 1 << endl;
        }
        else cout << -1 << endl;
    }
    return 0;
}
0