結果
| 問題 |
No.2725 Coprime Game 2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-12 22:06:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 37 ms / 2,000 ms |
| コード長 | 515 bytes |
| コンパイル時間 | 477 ms |
| コンパイル使用メモリ | 64,000 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-02 23:20:10 |
| 合計ジャッジ時間 | 1,331 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 |
ソースコード
#include<iostream>
#include<cassert>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;cin>>T;
for(;T--;)
{
long N;
cin>>N;
int t=2;
while(N%t==0)t++;
if(N<t)
{
cout<<"P\n";
continue;
}
{
int u=t;
bool a=false,b=false;
for(int p=2;p*p<=u;p++)if(u%p==0)
{
if(N%p==0)a=true;
else if(t+p<N)b=true;
while(u%p==0)u/=p;
}
if(u>1)
{
if(N%u==0)a=true;
else if(t+u<N)b=true;
}
cout<<(b||!a?"K\n":"P\n");
}
}
}