結果

問題 No.1140 EXPotentiaLLL!
ユーザー sbitesbite
提出日時 2020-07-31 22:28:48
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 221 ms / 2,000 ms
コード長 1,825 bytes
コンパイル時間 2,267 ms
コンパイル使用メモリ 202,008 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 00:09:34
合計ジャッジ時間 6,508 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 215 ms
4,376 KB
testcase_01 AC 211 ms
4,380 KB
testcase_02 AC 221 ms
4,376 KB
testcase_03 AC 151 ms
4,376 KB
testcase_04 AC 123 ms
4,380 KB
testcase_05 AC 178 ms
4,376 KB
testcase_06 AC 170 ms
4,380 KB
testcase_07 AC 212 ms
4,376 KB
testcase_08 AC 32 ms
4,376 KB
testcase_09 AC 32 ms
4,380 KB
testcase_10 AC 32 ms
4,376 KB
testcase_11 AC 32 ms
4,376 KB
testcase_12 AC 32 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;

ll frac(int n, int m)
{
    if (n == 0)
        return 1;
    return (frac(n - 1, m) * n) % m;
    ;
}

vector<bool> make_prime()
{
    vector<bool> isPrime(5 * 1010101, true);

    isPrime[0] = false;
    isPrime[1] = false;

    rep(i, 2, 5 * 1010101)
    {
        if (isPrime[i] == false)
        {
            continue;
        }
        for (int j = i + i; j < 5 * 1010101; j += i)
        {
            isPrime[j] = false;
        }
    }
    return isPrime;
}

ll mpow(ll base, ll num, ll mod)
{
    if (num == 0)
        return 1;
    ll prev = mpow(base, num / 2, mod);
    if (num % 2 == 0)
    {
        return (prev * prev) % mod;
    }
    else
    {
        return (((prev * prev) % mod) * base) % mod;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    auto isPrime = make_prime();
    int t;
    cin >> t;
    rep(i, t)
    {
        ll a, p;
        cin >> a >> p;
        if (isPrime[p])
        {
            if (a % p == 0)
            {
                cout << 0 << "\n";
            }
            else
            {
                cout << 1 << "\n";
            }
        }
        else
        {
            cout << -1 << "\n";
        }
    }
    return 0;
}
0