結果

問題 No.1140 EXPotentiaLLL!
ユーザー HaarHaar
提出日時 2020-07-31 21:41:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 836 bytes
コンパイル時間 1,975 ms
コンパイル使用メモリ 198,600 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-20 22:22:15
合計ジャッジ時間 5,724 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 198 ms
4,376 KB
testcase_01 AC 200 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 150 ms
4,380 KB
testcase_04 AC 120 ms
4,380 KB
testcase_05 AC 171 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 33 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 34 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

/**
 * @title Sieve of Eratosthenes
 * @docs eratosthenes_sieve.md
 */
template <int MAX>
struct EratosthenesSieve{
  static std::bitset<MAX+1> is_prime;
  
  static void init(){
    is_prime.flip();
    is_prime[0] = is_prime[1] = false;
    
    for(int i = 2; i <= MAX; ++i){
      if(is_prime[i]){
        for(int j = 2*i; j <= MAX; j += i){
          is_prime[j] = false;
        }
      }
    }
  }
};

template <int MAX> std::bitset<MAX+1> EratosthenesSieve<MAX>::is_prime;


using E = EratosthenesSieve<5000000>;

int main(){
  E::init();
  
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  
  int T; std::cin >> T;

  while(T--){
    int64_t A, P; std::cin >> A >> P;

    if(E::is_prime[P]){
      std::cout << 1 << "\n";
    }else{
      std::cout << -1 << "\n";
    }
  }
  

  return 0;
}
0