結果
問題 | No.1140 EXPotentiaLLL! |
ユーザー | ks115 |
提出日時 | 2021-11-21 16:42:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,309 ms / 2,000 ms |
コード長 | 687 bytes |
コンパイル時間 | 2,048 ms |
コンパイル使用メモリ | 195,996 KB |
最終ジャッジ日時 | 2025-01-26 00:03:56 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h> #define REP(i, s, n) for (int i = s; i < (int)(n); i++) #define ALL(a) a.begin(), a.end() #define MOD 1000000007 using namespace std; using ll = long long; const int N = 5e6; vector<bool> primes(N + 1, true); void init() { primes[0] = primes[1] = false; for (int i = 2; i * i <= N; i++) { if (!primes[i]) continue; for (int j = 2 * i; j <= N; j += i) primes[j] = false; } } int main() { init(); int T; cin >> T; while (T--) { ll A; int P; cin >> A >> P; if (primes[P]) { cout << (A % P == 0 ? 0 : 1) << endl; } else { cout << -1 << endl; } } return 0; }