結果

問題 No.1140 EXPotentiaLLL!
ユーザー DaYuanChiDaYuanChi
提出日時 2021-04-05 00:28:00
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 632 bytes
コンパイル時間 2,030 ms
コンパイル使用メモリ 163,732 KB
実行使用メモリ 28,136 KB
最終ジャッジ日時 2023-08-28 12:06:40
合計ジャッジ時間 17,399 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,461 ms
27,884 KB
testcase_01 AC 1,468 ms
27,828 KB
testcase_02 AC 1,470 ms
27,816 KB
testcase_03 AC 1,145 ms
27,748 KB
testcase_04 AC 960 ms
27,884 KB
testcase_05 AC 1,339 ms
27,760 KB
testcase_06 WA -
testcase_07 AC 1,510 ms
28,136 KB
testcase_08 AC 298 ms
27,892 KB
testcase_09 AC 294 ms
28,088 KB
testcase_10 AC 295 ms
27,736 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; ll 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