結果
問題 |
No.2724 Coprime Game 1
|
ユーザー |
|
提出日時 | 2024-12-20 17:31:01 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 143 ms / 2,000 ms |
コード長 | 756 bytes |
コンパイル時間 | 6,103 ms |
コンパイル使用メモリ | 336,648 KB |
実行使用メモリ | 38,472 KB |
最終ジャッジ日時 | 2024-12-20 17:31:13 |
合計ジャッジ時間 | 8,117 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 7 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> constexpr int N = 3e6; int main() { std::cin.tie(nullptr)->sync_with_stdio(false); int st[N + 1]{}; for (int i = 2; i * i <= N; ++i) { if (st[i]) continue; for (int j = i * i; j <= N; j += i) st[j] = i; } atcoder::dsu d(N + 1); int res[N + 1]{}; for (int i = 2; i <= N; ++i) { if (st[i]) { d.merge(i, st[i]); int x = i; while (x % st[i] == 0) x /= st[i]; if (x > 1) d.merge(i, x); } res[i] = d.size(i) & 1; } int q; std::cin >> q; while (q--) { int n; std::cin >> n; std::cout << (res[n] ? "P" : "K") << '\n'; } return 0; }