結果

問題 No.1140 EXPotentiaLLL!
ユーザー motmot
提出日時 2020-08-01 01:11:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,224 ms / 2,000 ms
コード長 914 bytes
コンパイル時間 558 ms
コンパイル使用メモリ 81,972 KB
実行使用メモリ 8,400 KB
最終ジャッジ日時 2023-09-21 05:00:39
合計ジャッジ時間 12,075 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,199 ms
8,188 KB
testcase_01 AC 1,224 ms
8,188 KB
testcase_02 AC 1,207 ms
8,124 KB
testcase_03 AC 895 ms
8,188 KB
testcase_04 AC 694 ms
8,116 KB
testcase_05 AC 1,078 ms
8,172 KB
testcase_06 AC 1,035 ms
8,400 KB
testcase_07 AC 1,200 ms
8,208 KB
testcase_08 AC 41 ms
8,156 KB
testcase_09 AC 41 ms
8,176 KB
testcase_10 AC 41 ms
8,188 KB
testcase_11 AC 41 ms
8,208 KB
testcase_12 AC 39 ms
8,152 KB
権限があれば一括ダウンロードができます

ソースコード

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() {
  bool prime[5000005];
  for(int i=0;i<5000005;++i) prime[i] = true;
  prime[0] = false;
  prime[1] = false;
  for(int i=2;i<5000005;++i) {
    if(!prime[i]) continue;
    for(int j=2;i*j<5000005;++j) {
      prime[i*j] = false;
    }
  }
  int T;
  cin>>T;
  ll A, P;
  for(int j=0;j<T;++j) {
    cin>>A>>P;
    if(!prime[P]) {
      cout<<-1<<endl;
      continue;
    }
    if(A%P==0) cout<<0<<endl;
    else cout<<1<<endl;
  }
}
0