結果
問題 |
No.2725 Coprime Game 2
|
ユーザー |
|
提出日時 | 2024-04-12 22:38:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 832 bytes |
コンパイル時間 | 2,033 ms |
コンパイル使用メモリ | 194,944 KB |
最終ジャッジ日時 | 2025-02-21 00:33:29 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 2 WA * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while(T--){ long long N; cin >> N; if(N == 2){cout << "P" << endl; continue;} int first = -1,last = -1; for(int i=2; i<=N; i++){ if(N%i == 0) continue; if(last == -1) last = i; int g = gcd(N,i); if(g != 1) continue; first = i; break; } if(last == first) cout << "K" << endl; else{ int now = first*2,yes = 0; while(now <= N){ int g = gcd(N,now); if(g == 1){yes = 1; break;} now += first; } if(yes) cout << "K" << endl; else cout << "P" << endl; } } }