結果
| 問題 |
No.2724 Coprime Game 1
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-23 04:58:52 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,036 bytes |
| コンパイル時間 | 3,486 ms |
| コンパイル使用メモリ | 247,632 KB |
| 実行使用メモリ | 15,148 KB |
| 最終ジャッジ日時 | 2024-12-20 18:45:55 |
| 合計ジャッジ時間 | 6,485 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 2 WA * 5 |
ソースコード
#include <bits/stdc++.h>
//#include <atcoder/modint>
using namespace std;
//using namespace atcoder;
//using mint = modint998244353;
#define rep(i,n) for(long long i=0;i<n;i++)
#define rep1(i,n) for(long long i=1;i<=n;i++)
#define Rep(i,a,b) for(long long i=a;i<=b;i++)
#define all(a) (a).begin(), (a).end()
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> vvec;
typedef vector<long long> vecll;
typedef vector<vector<long long>> vvecll;
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
const ll mod=998244353;
//const ll mod=1e9+7;
const ll INF=5e18;
const int INT_INF=1e9;
const double pi=3.14159265358979;
//xのn乗をpで割ったあまりを求める
ll modpow(ll x,ll n,ll p=mod){
if(n==0) return 1;
if(n%2==1) return (x*modpow(x,n-1,p))%p;
else{
ll t=modpow(x,n/2,p);
assert(t>0);
return (t*t)%p;
}
}
//xの逆元(p:素数)
ll inv(ll x,ll p=mod){
return modpow(x,p-2,p);
}
template <typename T>
int index(vector<T> &a, T x){
return lower_bound(all(a),x)-a.begin();
}
vector<int> spf(int n){
vector<int> res(n+1,0);
iota(all(res),0);
for(int i=2;i<=n;i++){
for(int j=i;j<=n;j+=i){
res[j]=min(res[j],i);
}
}
return res;
}
int main(){
int t;
cin >> t;
vec table=spf(3000000);
rep(_,t){
int n;
cin >> n;
int b=0,x=n;
vec s;
while(x>1){
if(b!=table[x]){
b=table[x];
s.push_back(b);
}
x/=table[x];
}
int ans=0;
int k=s.size();
rep1(i,(1<<k)-1){
int cnt=0,y=1;
int bb=i;
rep(j,k){
if(bb%2==1){
cnt++;
y*=s[j];
}
bb/=2;
}
if(cnt%2==1){
ans+=(n-1)/y;
}else{
ans-=(n-1)/y;
}
}
//cout << ans << endl;
//rep(i,k) cout << s[i] << " ";
//cout << endl;
if(ans%2==0){
cout << 'P' << endl;
}else{
cout << 'K' << endl;
}
}
return 0;
}