結果
問題 |
No.1140 EXPotentiaLLL!
|
ユーザー |
|
提出日時 | 2021-05-29 18:21:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,247 ms / 2,000 ms |
コード長 | 616 bytes |
コンパイル時間 | 1,688 ms |
コンパイル使用メモリ | 168,208 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 01:22:43 |
合計ジャッジ時間 | 13,543 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define P pair<int, int> int main() { vector<bool> memo(5000005, true); memo[1] = false; for (int i = 2; i <= 5000000; i++) { if (memo[i]) { for (int j = i*2; j <= 5000000; j += i) memo[j] = false; } } auto isPrime = [&](int x) { return memo[x]; }; int t; cin >> t; rep(ti, t) { ll a; int p; cin >> a >> p; if (isPrime(p)) { if (a%p == 0) cout << 0 << endl; else cout << 1 << endl; } else { cout << -1 << endl; } } }