結果

問題 No.1140 EXPotentiaLLL!
ユーザー abc3abc3
提出日時 2020-08-01 16:04:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,250 ms / 2,000 ms
コード長 702 bytes
コンパイル時間 1,839 ms
コンパイル使用メモリ 166,548 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-22 10:52:21
合計ジャッジ時間 14,550 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,236 ms
4,380 KB
testcase_01 AC 1,227 ms
4,376 KB
testcase_02 AC 1,237 ms
4,376 KB
testcase_03 AC 907 ms
4,380 KB
testcase_04 AC 703 ms
4,380 KB
testcase_05 AC 1,104 ms
4,384 KB
testcase_06 AC 1,052 ms
4,380 KB
testcase_07 AC 1,250 ms
4,380 KB
testcase_08 AC 59 ms
4,384 KB
testcase_09 AC 59 ms
4,384 KB
testcase_10 AC 58 ms
4,504 KB
testcase_11 AC 59 ms
4,380 KB
testcase_12 AC 59 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<bool> prime(5000005,true);
void eratosthenes(){
  prime[0]=false;prime[1]=false;
  for(int i=2;i*i<=5000005;i++){
    for(int j=2;j<=5000005/i;j++){
      prime[i*j]=false;
    }
  }
}
int main() {
  int T;
  cin>>T;
  eratosthenes();
  for(int i=0;i<T;i++){
    int64_t A,P;
    cin>>A>>P;
    if(prime[P]){
      if(__gcd(A,P)==1){cout<<1<<endl;}
      else{cout<<0<<endl;}
    }
    else{cout<<-1<<endl;}
  }
  return 0;
}
0