結果

問題 No.1140 EXPotentiaLLL!
ユーザー DaYuanChiDaYuanChi
提出日時 2021-04-05 00:26:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 633 bytes
コンパイル時間 1,487 ms
コンパイル使用メモリ 163,752 KB
実行使用メモリ 28,076 KB
最終ジャッジ日時 2023-08-28 12:04:38
合計ジャッジ時間 18,286 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,468 ms
27,760 KB
testcase_01 AC 1,491 ms
28,064 KB
testcase_02 AC 1,485 ms
27,768 KB
testcase_03 AC 1,200 ms
27,780 KB
testcase_04 AC 953 ms
27,796 KB
testcase_05 AC 1,378 ms
27,760 KB
testcase_06 WA -
testcase_07 AC 1,487 ms
27,768 KB
testcase_08 AC 293 ms
27,764 KB
testcase_09 AC 290 ms
28,064 KB
testcase_10 AC 288 ms
27,756 KB
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 5e6;
bool is_prime[N+5];
int d[N+5]; //d[i]=iの最小の素因数

int main(){
  for(int i = 0; i < N; i++) is_prime[i]=true; //エラトステネス
  for(int i = 2; i < N; i++){
    if(is_prime[i]) d[i] = i;
    for(int j = i + i; j < N; j += i){
      is_prime[j] = false;
      if(is_prime[i] && d[j]==0) d[j] = i;
    }
  }
  int t; cin >> t;
  for(int i = 0; i < t; i++){
    ll a; int p; cin >> a >> p;
    if(is_prime[p]){
      if(a%p!=0) cout << 1 << endl;
      else cout << 0 << endl;
    }
    else cout << -1 << endl;
  }
  return 0;
}
0