結果

問題 No.2721 "Don't say N" Game
ユーザー tnakao0123
提出日時 2024-04-30 15:06:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 427 bytes
コンパイル時間 479 ms
コンパイル使用メモリ 57,364 KB
最終ジャッジ日時 2025-02-21 09:53:39
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |   scanf("%d", &tn);
      |   ~~~~~^~~~~~~~~~~
main.cpp:20:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2721.cc:  No.2721 "Don't say N" Game - yukicoder
 */

#include<cstdio>
#include<cmath>
#include<algorithm>
 
using namespace std;

/* main */

int main() {
  int tn;
  scanf("%d", &tn);

  while (tn--) {
    int n;
    scanf("%d", &n);

    if (n == 1) puts("P");
    else {
      int r = sqrt(n + 0.5);
      if (r * r == n) puts("P");
      else puts("K");
    }
  }

  return 0;
}
0