結果

問題 No.1140 EXPotentiaLLL!
ユーザー SSRSSSRS
提出日時 2020-07-31 21:25:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 1,384 ms
コンパイル使用メモリ 166,856 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 21:28:16
合計ジャッジ時間 5,312 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 221 ms
4,376 KB
testcase_01 AC 214 ms
4,376 KB
testcase_02 AC 230 ms
4,376 KB
testcase_03 AC 157 ms
4,376 KB
testcase_04 AC 127 ms
4,380 KB
testcase_05 AC 186 ms
4,380 KB
testcase_06 AC 175 ms
4,384 KB
testcase_07 AC 218 ms
4,380 KB
testcase_08 AC 37 ms
4,380 KB
testcase_09 AC 37 ms
4,376 KB
testcase_10 AC 38 ms
4,376 KB
testcase_11 AC 37 ms
4,376 KB
testcase_12 AC 37 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin >> T;
  vector<bool> prime(5000001, true);
  prime[0] = false;
  prime[1] = false;
  for (int i = 2; i <= 5000000; i++){
    if (prime[i]){
      for (int j = i * 2; j <= 5000000; j += i){
        prime[j] = false;
      }
    }
  }
  for (int i = 0; i < T; i++){
    long long A;
    int P;
    cin >> A >> P;
    if (!prime[P]){
      cout << -1 << "\n";
    } else if (A % P == 0){
      cout << 0 << "\n";
    } else {
      cout << 1 << "\n";
    }
  }
}
0