結果

問題 No.1140 EXPotentiaLLL!
ユーザー zezerozezero
提出日時 2021-11-22 21:09:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,287 ms / 2,000 ms
コード長 747 bytes
コンパイル時間 4,982 ms
コンパイル使用メモリ 157,188 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 15:52:07
合計ジャッジ時間 15,431 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,251 ms
4,376 KB
testcase_01 AC 1,266 ms
4,376 KB
testcase_02 AC 1,287 ms
4,384 KB
testcase_03 AC 912 ms
4,376 KB
testcase_04 AC 730 ms
4,380 KB
testcase_05 AC 1,112 ms
4,380 KB
testcase_06 AC 1,066 ms
4,376 KB
testcase_07 AC 1,224 ms
4,376 KB
testcase_08 AC 93 ms
4,380 KB
testcase_09 AC 93 ms
4,380 KB
testcase_10 AC 94 ms
4,380 KB
testcase_11 AC 93 ms
4,384 KB
testcase_12 AC 93 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cstring>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)

int main(){
  vector<bool> prime(5000002,true);
  prime[1] = false;
  prime[2] = true;
  for (int i = 2; i <= 5000000;i++){
    for (int j = i+i; j <= 5000000;j+=i){
      prime[j] = false;
    }
  }
  int t;
  cin >> t;
  while(t--){
    ll a,p;
    cin >> a >> p;
    if (prime[p]){
      if (a%p == 0){
        cout << 0 << endl;
      }
      else cout << 1 << endl;
    }
    else cout << -1 << endl;
  } 
  return 0;
}
0