結果

問題 No.1140 EXPotentiaLLL!
ユーザー chocono2230chocono2230
提出日時 2020-07-31 22:17:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,725 ms / 2,000 ms
コード長 1,046 bytes
コンパイル時間 1,641 ms
コンパイル使用メモリ 171,732 KB
実行使用メモリ 20,036 KB
最終ジャッジ日時 2023-09-20 23:50:47
合計ジャッジ時間 17,055 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,475 ms
19,976 KB
testcase_01 AC 1,455 ms
19,868 KB
testcase_02 AC 1,457 ms
19,900 KB
testcase_03 AC 1,311 ms
19,892 KB
testcase_04 AC 1,045 ms
19,932 KB
testcase_05 AC 1,573 ms
20,036 KB
testcase_06 AC 1,478 ms
19,976 KB
testcase_07 AC 1,725 ms
19,904 KB
testcase_08 AC 172 ms
19,852 KB
testcase_09 AC 171 ms
19,904 KB
testcase_10 AC 170 ms
19,960 KB
testcase_11 AC 170 ms
19,968 KB
testcase_12 AC 170 ms
19,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

set<int> make_prime_set(int lim){
  set<int> ps;
  vector<bool> chk(lim+1, true);
  chk.at(0) = chk.at(1) = false;
  rep2(i, 2, chk.size()){
    if(chk.at(i) == false) continue;
    ps.insert(i);
    for(int j = i+i; j < chk.size(); j +=i) chk.at(j) = false;
  }
  return ps;
}

int main(){
  int qe;
  cin >> qe;
  auto ps = make_prime_set(5000000);
rep(_q, qe){
  ll a, p;
  cin >> a >> p;
  if(ps.find(p) == ps.end()){
    cout << -1 << endl;
    continue;
  }
  if(a % p == 0){
    cout << 0 << endl;
  }else{
    cout << 1 << endl;
  }
}
  return 0;
}
0