結果
問題 |
No.1140 EXPotentiaLLL!
|
ユーザー |
|
提出日時 | 2024-10-27 10:33:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 687 ms / 2,000 ms |
コード長 | 742 bytes |
コンパイル時間 | 1,978 ms |
コンパイル使用メモリ | 195,432 KB |
最終ジャッジ日時 | 2025-02-25 00:47:31 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, s, e) for (int i = (int)s; i < (int)e; ++i) #define all(a) (a).begin(), (a).end() int main() { cin.tie(nullptr); int T; cin >> T; vector<bool> isPrime(5e6 + 1, true); isPrime[0] = false; isPrime[1] = false; rep(p, 2, 5e6) { if (!isPrime[p]) continue; for (int q = p * 2; q <= 5e6; q += p) isPrime[q] = false; } rep(test, 0, T) { ll A, P; cin >> A >> P; if (!isPrime[P]) { cout << -1 << '\n'; continue; } ll g = gcd(A, P); if (g != 1) cout << 0 << '\n'; else cout << 1 << '\n'; } }