結果

問題 No.1140 EXPotentiaLLL!
ユーザー どららどらら
提出日時 2020-08-01 00:54:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,231 ms / 2,000 ms
コード長 841 bytes
コンパイル時間 1,570 ms
コンパイル使用メモリ 163,644 KB
実行使用メモリ 9,440 KB
最終ジャッジ日時 2023-09-21 04:35:34
合計ジャッジ時間 13,209 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,210 ms
9,252 KB
testcase_01 AC 1,225 ms
9,172 KB
testcase_02 AC 1,231 ms
9,272 KB
testcase_03 AC 904 ms
9,196 KB
testcase_04 AC 690 ms
9,236 KB
testcase_05 AC 1,095 ms
9,388 KB
testcase_06 AC 1,047 ms
9,224 KB
testcase_07 AC 1,215 ms
9,196 KB
testcase_08 AC 48 ms
9,440 KB
testcase_09 AC 48 ms
9,236 KB
testcase_10 AC 49 ms
9,192 KB
testcase_11 AC 47 ms
9,296 KB
testcase_12 AC 48 ms
9,184 KB
権限があれば一括ダウンロードができます

ソースコード

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{
      if(A%P==0) cout << 0 << endl;
      else cout << 1 << endl;
    }
  }
  
  return 0;
}

0