結果

問題 No.1140 EXPotentiaLLL!
ユーザー bonKotsubonKotsu
提出日時 2021-05-29 18:21:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,263 ms / 2,000 ms
コード長 616 bytes
コンパイル時間 1,840 ms
コンパイル使用メモリ 165,372 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 14:23:25
合計ジャッジ時間 13,897 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,252 ms
6,812 KB
testcase_01 AC 1,259 ms
6,940 KB
testcase_02 AC 1,263 ms
6,944 KB
testcase_03 AC 891 ms
6,944 KB
testcase_04 AC 694 ms
6,940 KB
testcase_05 AC 1,111 ms
6,940 KB
testcase_06 AC 1,050 ms
6,944 KB
testcase_07 AC 1,228 ms
6,940 KB
testcase_08 AC 49 ms
6,940 KB
testcase_09 AC 48 ms
6,944 KB
testcase_10 AC 50 ms
6,944 KB
testcase_11 AC 49 ms
6,940 KB
testcase_12 AC 50 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

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);
  memo[1] = false; 
  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