結果

問題 No.1140 EXPotentiaLLL!
ユーザー beetbeet
提出日時 2020-07-31 21:34:08
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,554 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 2,300 ms
コンパイル使用メモリ 197,792 KB
実行使用メモリ 81,764 KB
最終ジャッジ日時 2023-09-20 22:01:59
合計ジャッジ時間 24,621 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,526 ms
81,504 KB
testcase_01 AC 1,536 ms
81,508 KB
testcase_02 AC 1,524 ms
81,612 KB
testcase_03 AC 1,478 ms
81,492 KB
testcase_04 AC 1,467 ms
81,764 KB
testcase_05 AC 1,521 ms
81,596 KB
testcase_06 AC 1,508 ms
81,476 KB
testcase_07 AC 1,554 ms
81,724 KB
testcase_08 AC 1,367 ms
81,644 KB
testcase_09 AC 1,323 ms
81,468 KB
testcase_10 AC 1,356 ms
81,536 KB
testcase_11 AC 1,335 ms
81,496 KB
testcase_12 AC 1,360 ms
81,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
const Int MAX = 1e7;
Int dp[MAX]={};
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  for(Int i=2;i<MAX;i++)
    for(Int j=i+i;j<MAX;j+=i) dp[j]++;

  dp[0]=dp[1]=1;

  Int T;
  cin>>T;
  while(T--){
    Int A,P;
    cin>>A>>P;
    if(dp[P]) cout<<-1<<newl;
    else cout<<(A%P==0?0:1)<<newl;
  }
  return 0;
}
0