結果

問題 No.1140 EXPotentiaLLL!
ユーザー zezero
提出日時 2021-11-22 21:06:11
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 727 bytes
コンパイル時間 2,998 ms
コンパイル使用メモリ 157,812 KB
最終ジャッジ日時 2025-01-26 00:25:00
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cstring>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

int main(){
  vector<bool> prime(5000002,true);
  prime[2] = true;
  for (int i = 2; i <= 5000000;i++){
    for (int j = i+i; j <= 5000000;j+=i){
      prime[j] = false;
    }
  }
  int t;
  cin >> t;
  while(t--){
    ll a,p;
    cin >> a >> p;
    if (prime[p]){
      if (a%p == 0){
        cout << 0 << endl;
      }
      else cout << 1 << endl;
    }
    else cout << -1 << endl;
  } 
  return 0;
}
0