結果

問題 No.1140 EXPotentiaLLL!
ユーザー beetbeet
提出日時 2020-10-05 22:39:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 808 ms / 2,000 ms
コード長 594 bytes
コンパイル時間 1,797 ms
コンパイル使用メモリ 197,260 KB
実行使用メモリ 42,712 KB
最終ジャッジ日時 2023-09-27 04:34:03
合計ジャッジ時間 14,535 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 609 ms
42,428 KB
testcase_01 AC 625 ms
42,436 KB
testcase_02 AC 799 ms
42,444 KB
testcase_03 AC 753 ms
42,496 KB
testcase_04 AC 716 ms
42,564 KB
testcase_05 AC 800 ms
42,628 KB
testcase_06 AC 764 ms
42,496 KB
testcase_07 AC 808 ms
42,440 KB
testcase_08 AC 608 ms
42,712 KB
testcase_09 AC 610 ms
42,452 KB
testcase_10 AC 603 ms
42,432 KB
testcase_11 AC 609 ms
42,448 KB
testcase_12 AC 604 ms
42,440 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 = 5e6+10;
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