結果

問題 No.2725 Coprime Game 2
ユーザー 沙耶花沙耶花
提出日時 2024-04-12 23:04:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 1,909 bytes
コンパイル時間 4,783 ms
コンパイル使用メモリ 261,648 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-12 23:04:22
合計ジャッジ時間 6,961 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
map<long long,long long> mp;

int get(long long n,long long c){
	if(mp.count(c))return mp[c];
	for(long long i=2;i<c;i++){
		if(gcd(c,i)!=1)continue;
		if(n%i==0)continue;
		if(get(n,i)==0){
			mp[c] = 1;
			return 1;
		}
	}
	mp[c] = 0;
	return 0;
}

int main(){
	/*
	for(long long i=2;i<=100000;i++){
		mp.clear();
		if(get(i,i)==0){
			if(i%12!=6 && i%420!=0)cout<<'a'<<i<<endl;
		}
		else{
			if(i%12==6 || i%420==0)cout<<'b'<<i<<endl;
		}
		
		//if(get(i,i)==0)cout<<i<<endl;
	}
	*/
	/*
	for(long long i=720720;true;i+=720720){
		mp.clear();
		if(get(i,i)==0){
			cout<<i<<endl;
		}
	}
*/
	vector<long long> t = {4,7,10,16,23,27,32};
	rep(i,t.size()){
		long long x = 1;
		rep(j,t[i])x = lcm(x,j+1);
		t[i] = x;
	}
	//cout<<t[6]<<endl;
	//cout<<(t[6]+t[6]/2)%t[5]<<endl;
	//cout<<get(t[6]+t[6]/2,t[6]+t[6]/2)<<endl;
	reverse(t.begin(),t.end());
	t.push_back(1);
	/*
	long long t = 1;
	rep(i,41)t = lcm(t,i+1);
	cout<<t<<endl;
	cout<<get(t,t)<<endl;
	mp.clear();
	cout<<get(t+t/2,t+t/2)<<endl;
	*/
	//cout<<t<<endl;
	/*
	cout<<t<<endl;
	cout<<get(t+t/2,t+t/2)<<endl;
	t *= 60060;
	mp.clear();
	cout<<get(t+t/2,t+t/2)<<endl;
	*/
	int _t;
	cin>>_t;
	rep(_,_t){
		long long n;
		cin>>n;
		if(n==2)cout<<"P"<<endl;
		else{
			rep(i,t.size()){
				if(i%3==0){
					if(n%t[i]==t[i]/2){
						cout<<"P"<<endl;
						break;
					}
				}
				if(i%3==1){
					if(n%t[i]==0){
						cout<<"K"<<endl;
						break;
					}
				}
				if(i%3==2){
					if(n%t[i]==0){
						cout<<"P"<<endl;
						break;
					}
				}
			}
			
		}
		//if(n==2 || n%12==6 || (n%420==0 && n%2520!=0) || n%720720==360360 || n%t==(t/2))cout<<"P"<<endl;
		//else cout<<"K"<<endl;
	}
	
	return 0;
}
0