結果

問題 No.1140 EXPotentiaLLL!
ユーザー umezoumezo
提出日時 2020-07-31 22:00:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,901 ms / 2,000 ms
コード長 571 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 31,468 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 23:18:21
合計ジャッジ時間 10,281 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,901 ms
4,376 KB
testcase_01 AC 184 ms
4,376 KB
testcase_02 AC 1,899 ms
4,376 KB
testcase_03 AC 212 ms
4,380 KB
testcase_04 AC 162 ms
4,380 KB
testcase_05 AC 257 ms
4,376 KB
testcase_06 AC 247 ms
4,380 KB
testcase_07 AC 1,289 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <stdio.h>
using namespace std;

int isPrime(int x){
  if(x<2) return 0;
  else if(x==2) return 1;
  if(x%2==0) return 0;
  for(int i=3;i*i<=x;i+=2){
    if(x%i==0) return 0;
  }
  return 1;
}

int main(){
  int t;
  scanf("%d", &t);
  
  while(t--){
    ll a,p;
    scanf("%lld %lld", &a,&p);
    
    if(!isPrime(p)){
      printf("%d\n",-1);
      continue;
    }
    
    if(a%p==0) printf("%d\n",0); 
    else printf("%d\n",1);
  }
  
  return 0;
}
0