結果

問題 No.2721 "Don't say N" Game
ユーザー MasKoaTS
提出日時 2023-10-05 22:47:56
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 1,582 ms
コンパイル使用メモリ 193,044 KB
最終ジャッジ日時 2025-02-17 04:33:21
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;


int isqrt(int n){
    int ok = 0;
    int ng = 32;
    while(abs(ok - ng) > 1){
        int mid = (ok + ng) >> 1;
        if(mid * mid <= n){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    return ok;
}


int main(){
    int t;  cin >> t;
    for(int i = 0; i < t; ++i){
        int n;   cin >> n;
        int k = isqrt(n);
        char ans = (k * k == n) ? 'P' : 'K';
        cout << ans << endl;
    }

    return 0;
}
0