結果

問題 No.1140 EXPotentiaLLL!
ユーザー どらら
提出日時 2020-08-01 00:51:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 787 bytes
コンパイル時間 1,514 ms
コンパイル使用メモリ 165,712 KB
実行使用メモリ 9,472 KB
最終ジャッジ日時 2024-07-06 23:07:04
合計ジャッジ時間 13,346 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 6 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

#define MAX_PRIME 6000000
bool isprime[MAX_PRIME+1];
void init_prime(){
  fill(isprime, isprime+MAX_PRIME+1, true);
  isprime[0] = isprime[1] = false;
  for(int i = 2; i <= MAX_PRIME; i++) {
    if (isprime[i]) {
      for(int j = i*2; j <= MAX_PRIME; j += i)
      isprime[j] = false;
    }
  }
}

int main(){
  init_prime();
  
  int T;
  cin >> T;
  rep(t,T){
    ll A, P;
    cin >> A >> P;

    if(!isprime[P]) cout << -1 << endl;
    else cout << 1 << endl;
  }
  
  return 0;
}

0