結果

問題 No.2725 Coprime Game 2
ユーザー hirakuuuuhirakuuuu
提出日時 2024-04-12 22:52:03
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 252 ms / 2,000 ms
コード長 1,261 bytes
コンパイル時間 3,601 ms
コンパイル使用メモリ 274,656 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-12 22:52:09
合計ジャッジ時間 5,914 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, n) for(int i = a; i < n; i++)
#define rrep(i, a, n) for(int i = a; i >= n; i--)
#define inr(l, x, r) (l <= x && x < r)
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
// constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
constexpr int IINF = 1001001001;
constexpr ll INF = 9e18;

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

ll power(ll a, ll b, ll m=MOD){
    ll res = 1;
    while(b > 0){
        if(b%2 == 1) res = res*a%m;
        a = a*a%m;
        b /= 2;
    }
    return res;
}

int main(){
    int t; cin >> t;
    while(t--){
        ll n; cin >> n;
        if(n == 2){
            cout << "P" << endl;
            continue;
        }

        ll total = 1, tmp = 2;
        bool f = false;
        while(1 <= n/tmp){
            total = lcm(total, tmp);
            if(n%total){
                if(gcd(n, tmp) != 1) cout << "P" << endl;
                else cout << "K" << endl;
                f = true;
                break;
            }
            tmp++;
        }
        if(f) continue;
        cout << "K" << endl;
        
    }
    return 0;
}
0