結果

問題 No.1140 EXPotentiaLLL!
ユーザー fastmathfastmath
提出日時 2020-07-31 21:25:27
言語 C++17(clang)
(14.0.0 + boost 1.83.0)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 1,015 bytes
コンパイル時間 7,155 ms
コンパイル使用メモリ 133,272 KB
実行使用メモリ 8,344 KB
最終ジャッジ日時 2023-09-20 21:27:52
合計ジャッジ時間 11,407 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 220 ms
8,312 KB
testcase_01 AC 216 ms
8,308 KB
testcase_02 AC 232 ms
8,328 KB
testcase_03 AC 176 ms
8,312 KB
testcase_04 AC 146 ms
8,312 KB
testcase_05 AC 213 ms
8,304 KB
testcase_06 AC 202 ms
8,336 KB
testcase_07 AC 242 ms
8,312 KB
testcase_08 AC 37 ms
8,300 KB
testcase_09 AC 38 ms
8,328 KB
testcase_10 AC 38 ms
8,292 KB
testcase_11 AC 37 ms
8,300 KB
testcase_12 AC 39 ms
8,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';

const int C = 5e6+7;
bool p[C];

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif

    for (int i = 2; i < C; ++i)
        p[i] = 1;
    for (int i = 2; i < C; ++i) {
        if (p[i]) {
            for (int j = i * 2; j < C; j += i)
                p[j] = 0;
        }   
    }   

    int t;
    cin >> t;
    while (t--) {
        int a, pp;
        cin >> a >> pp;
        if (!p[pp]) {
            cout << -1 << endl;
        }
        else if (a % pp == 0)
            cout << 0 << endl;
        else
            cout << 1 << endl;
    }   
}
0