結果

問題 No.2725 Coprime Game 2
ユーザー 👑 hitonanodehitonanode
提出日時 2024-04-12 22:36:29
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 410 bytes
コンパイル時間 743 ms
コンパイル使用メモリ 83,816 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-12 22:36:32
合計ジャッジ時間 1,938 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <numeric>
using namespace std;
using lint = long long;

bool solve(lint N) {
    lint m = 2;
    while (N % m == 0) ++m;

    if (m >= N) return false;

    return std::gcd(m, N) == 1;
}

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int T;
    cin >> T;
    while (T--) {
        lint N;
        cin >> N;
        cout << (solve(N) ? "K" : "P") << '\n';
    }
}
0