結果

問題 No.1140 EXPotentiaLLL!
ユーザー motmot
提出日時 2020-08-01 01:08:46
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 790 bytes
コンパイル時間 667 ms
コンパイル使用メモリ 82,168 KB
実行使用メモリ 12,024 KB
最終ジャッジ日時 2023-09-21 04:55:52
合計ジャッジ時間 7,906 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int T;
  cin>>T;
  ll A, P;
  for(int j=0;j<T;++j) {
    cin>>A>>P;
    bool prime = true;
    if(P==1)  prime = false;
    for(ll i=2;i*i<=P;++i) {
      if(P%i==0) prime = false;
    }
    if(!prime) {
      cout<<-1<<endl;
      continue;
    }
    if(A%P==0) cout<<0<<endl;
    else cout<<1<<endl;
  }
}
0