結果

問題 No.1140 EXPotentiaLLL!
ユーザー umezo
提出日時 2020-07-31 22:00:59
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 571 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 27,904 KB
最終ジャッジ日時 2025-01-12 10:05:17
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 11 TLE * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |   scanf("%d", &t);
      |   ~~~~~^~~~~~~~~~
main.cpp:24:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |     scanf("%lld %lld", &a,&p);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~

ソースコード

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