結果
問題 |
No.1140 EXPotentiaLLL!
|
ユーザー |
![]() |
提出日時 | 2025-04-07 00:54:07 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 212 ms / 2,000 ms |
コード長 | 757 bytes |
コンパイル時間 | 3,762 ms |
コンパイル使用メモリ | 275,756 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-04-07 00:54:16 |
合計ジャッジ時間 | 8,560 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); constexpr int n = 5'000'000; bitset<n + 1> is_prime; is_prime.flip(); is_prime.reset(0), is_prime.reset(1); for (int i = 2; i * i <= n; ++i) { if (is_prime.test(i)) { for (int j = i * i; j <= n; j += i) is_prime.reset(j); } } int t; cin >> t; while (t--) { ll a, p; cin >> a >> p; if (is_prime.test(p)) { cout << (gcd(a, p) == 1 ? 1 : 0) << '\n'; } else { cout << -1 << '\n'; } } return 0; }