結果

問題 No.1140 EXPotentiaLLL!
ユーザー kk
提出日時 2020-08-05 06:47:01
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 594 bytes
コンパイル時間 3,357 ms
コンパイル使用メモリ 198,584 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2023-10-13 14:23:09
合計ジャッジ時間 11,001 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 809 ms
8,188 KB
testcase_01 AC 806 ms
8,320 KB
testcase_02 WA -
testcase_03 AC 651 ms
8,176 KB
testcase_04 AC 496 ms
8,256 KB
testcase_05 AC 794 ms
8,172 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 21 ms
8,448 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 22 ms
8,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

template <size_t N>
void psieve(bool (&p)[N]) {
  for (int i = 0; i < N; i++)
    p[i] = true;
  p[0] = p[1] = false;
  for (int i = 2; i * i < N; i++) {
    if (!p[i])
      continue;
    for (int j = i * i; j < N; j += i)
      p[j] = false;
  }
}

bool prime[5000000+1];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  psieve(prime);

  int T;
  cin >> T;
  REP (i, T) {
    long long A;
    int P;
    cin >> A >> P;
    cout << (prime[P] ? 1 : -1) << endl;
  }
  
  return 0;
}
0