結果

問題 No.1140 EXPotentiaLLL!
ユーザー onsen_manjuuuonsen_manjuuu
提出日時 2020-08-01 01:08:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 554 bytes
コンパイル時間 1,452 ms
コンパイル使用メモリ 165,324 KB
実行使用メモリ 12,864 KB
最終ジャッジ日時 2023-09-21 04:56:03
合計ジャッジ時間 10,764 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 891 ms
12,652 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 98 ms
12,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long;

int MAX = 1e7;
vector<char> prime(MAX+1);
void f() {
    prime[0] = prime[1] = 1;
    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 {
        cout << (a % p == 0) << endl;
    }
}

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