結果

問題 No.2724 Coprime Game 1
ユーザー nononnonon
提出日時 2024-04-12 21:52:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 608 bytes
コンパイル時間 2,278 ms
コンパイル使用メモリ 200,212 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-12 21:52:30
合計ジャッジ時間 3,722 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
6,812 KB
testcase_01 AC 46 ms
6,816 KB
testcase_02 AC 45 ms
6,940 KB
testcase_03 AC 62 ms
6,944 KB
testcase_04 AC 110 ms
6,944 KB
testcase_05 AC 83 ms
6,944 KB
testcase_06 AC 65 ms
6,940 KB
testcase_07 AC 83 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
    }
}
0