結果
| 問題 |
No.2724 Coprime Game 1
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-20 17:35:52 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,855 ms / 2,000 ms |
| コード長 | 635 bytes |
| コンパイル時間 | 9,255 ms |
| コンパイル使用メモリ | 335,848 KB |
| 実行使用メモリ | 187,208 KB |
| 最終ジャッジ日時 | 2024-12-20 17:36:21 |
| 合計ジャッジ時間 | 25,352 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
constexpr int N = 3e6;
std::vector<int> g[N + 1];
int res[N + 1];
int main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
for (int i = 2; i <= N; ++i) {
if (!g[i].empty()) continue;
for (int j = i + i; j <= N; j += i)
g[j].push_back(i);
}
atcoder::dsu d(N + 1);
for (int i = 2; i <= N; ++i) {
for (auto &j : g[i])
d.merge(i, j);
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;
}