結果

問題 No.2724 Coprime Game 1
ユーザー ensembleaverageensembleaverage
提出日時 2024-04-12 21:59:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 2,855 bytes
コンパイル時間 1,966 ms
コンパイル使用メモリ 166,652 KB
実行使用メモリ 15,008 KB
最終ジャッジ日時 2024-04-12 21:59:19
合計ジャッジ時間 3,652 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
14,952 KB
testcase_01 AC 27 ms
14,916 KB
testcase_02 AC 27 ms
14,920 KB
testcase_03 AC 192 ms
14,904 KB
testcase_04 AC 217 ms
14,888 KB
testcase_05 AC 208 ms
15,008 KB
testcase_06 AC 106 ms
14,948 KB
testcase_07 AC 188 ms
14,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"


/*#include "boost/multiprecision/cpp_int.hpp"
namespace mp = boost::multiprecision;
using i128=mp::cpp_int;*/


using namespace std;
using namespace chrono;
typedef long long ll;
typedef int64_t i64;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pllll;
typedef vector<pii> vpii;
typedef vector<vector<pii>> vvpii;
typedef vector<vector<vector<pii>>> vvvpii;
typedef vector<pllll> vpllll;
typedef vector<vector<pllll>> vvpllll;
typedef vector<vector<vector<pllll>>> vvvpllll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define drep(i,a,n) for(int i=a;i>n;i--)
#define yes(ans) {if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;}
#define Yes(ans) {if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;}
#define YES(ans) {if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;}
#define printv(vec) {rep(first_,0,vec.size()) cout << vec[first_] << ' '; cout << endl;}
#define printvv(vec) {rep(first_,0,vec.size()) {rep(second_,0,vec[first_].size()) cout << vec[first_][second_] << ' '; cout << endl;}; cout<<endl;}
#define iINF 2000000007
#define lINF 10000000000007
#define llINF 9000000000000000007
#define all(x) x.begin(),x.end()
#define so(x) sort(all(x))
#define re(x) reverse(all(x))
#define mod 998244353
const double PI = acos(-1);

template <typename T>
vector<pair<T,T>> bunkai(T a){
   vector<pair<T,T>> nini(0);
   T y=a;
   for(T i=2;i*i<=y;i++){
       T count=0;
       while(1){
           if(a%i!=0) break;
           else{
               count++;
               a/=i;
           }
       }
       if(count!=0) nini.push_back({i,count});
   }
   if(a!=1) nini.push_back({a,1});
   return nini;
}

vi eratosu(int a){ //0オリジンだけど意味があるのは1~
    vi ans(a+1,1);
    if(a>1) ans[0]=0; ans[1]=0;
    for(int i=2;i*i<=a;i++){
        if(!ans[i]) continue;
        for(int j=i*i;j<=a;j+=i){
            ans[j]=0;
        }
    }
    return ans;
}

void solve(vi &ans){
    int n; cin>>n;
    /*vpii ans=bunkai<int>(n);
    int taga=n;
    int si=ans.size();
    rep(i,0,si){
        taga/=ans[i].first;
        taga*=ans[i].first-1;
    }
    if((n-taga)%2==0){
        cout<<'K'<<endl;
    }
    else cout<<'P'<<endl;*/
    if(ans[n]-ans[n-1]==1){
        cout<<'P'<<endl;
        return;
    }
    
    if((n-ans[n-1]+ans[n/2])%2==0){
        cout<<'P'<<endl;
    }
    else cout<<'K'<<endl;
    return;
}

int main(){
    int t; cin>>t;
    vi ans=eratosu(3000005);
    rep(i,3,3000005){
        ans[i]+=ans[i-1];
    }
    rep(i,0,t){
        solve(ans);
    }
}
0