結果
問題 | No.2724 Coprime Game 1 |
ユーザー | nonon |
提出日時 | 2024-04-12 21:52:26 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 79 ms / 2,000 ms |
コード長 | 608 bytes |
コンパイル時間 | 2,191 ms |
コンパイル使用メモリ | 204,308 KB |
実行使用メモリ | 5,864 KB |
最終ジャッジ日時 | 2024-10-02 23:13:48 |
合計ジャッジ時間 | 3,099 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 7 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); vector<int>P; vector<bool>ett(1<<22,1); ett[0]=ett[1]=0; for(int i=2;i<(1<<22);i++)if(ett[i]) { P.push_back(i); for(int j=i+i;j<(1<<22);j+=i)ett[j]=0; } int T; cin>>T; while(T--) { int N; cin>>N; if(ett[N]) { cout<<'P'<<'\n'; continue; } int n=lower_bound(P.begin(),P.end(),N)-lower_bound(P.begin(),P.end(),N/2+1); cout<<((N-n-1)%2==1?'P':'K')<<'\n'; } }