結果

問題 No.1140 EXPotentiaLLL!
ユーザー bonKotsubonKotsu
提出日時 2021-05-29 18:19:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 596 bytes
コンパイル時間 1,502 ms
コンパイル使用メモリ 167,124 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 14:20:31
合計ジャッジ時間 13,675 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,212 ms
6,812 KB
testcase_01 AC 1,236 ms
6,940 KB
testcase_02 AC 1,222 ms
6,940 KB
testcase_03 AC 890 ms
6,940 KB
testcase_04 AC 690 ms
6,940 KB
testcase_05 AC 1,088 ms
6,940 KB
testcase_06 WA -
testcase_07 AC 1,223 ms
6,940 KB
testcase_08 AC 44 ms
6,940 KB
testcase_09 AC 45 ms
6,944 KB
testcase_10 AC 44 ms
6,940 KB
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>


int main() {
  vector<bool> memo(5000005, true);
  for (int i = 2; i <= 5000000; i++) {
    if (memo[i]) {
      for (int j = i*2; j <= 5000000; j += i) memo[j] = false;
    }
  }

  auto isPrime = [&](int x) {
    return memo[x];
  };
  int t;
  cin >> t;
  rep(ti, t) {
    ll a;
    int p;
    cin >> a >> p;
    if (isPrime(p)) {
      if (a%p == 0) cout << 0 << endl;
      else cout << 1 << endl;
    } else {
      cout << -1 << endl;
    }
  }
}
0