結果
| 問題 |
No.2721 "Don't say N" Game
|
| コンテスト | |
| ユーザー |
ks2m
|
| 提出日時 | 2024-04-12 21:35:24 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 247 ms / 2,000 ms |
| コード長 | 725 bytes |
| コンパイル時間 | 2,198 ms |
| コンパイル使用メモリ | 75,248 KB |
| 実行使用メモリ | 43,384 KB |
| 最終ジャッジ日時 | 2024-10-02 23:04:08 |
| 合計ジャッジ時間 | 4,087 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 5 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for (int z = 0; z < t; z++) {
int n = sc.nextInt();
List<Integer> list = divList(n);
if (list.size() % 2 == 0) {
System.out.println("K");
} else {
System.out.println("P");
}
}
sc.close();
}
static List<Integer> divList(int n) {
List<Integer> list = new ArrayList<>();
int end = (int) Math.sqrt(n);
for (int i = 1; i <= end; i++) {
if (n % i == 0) {
list.add(i);
}
}
int i = end * end == n ? list.size() - 2 : list.size() - 1;
for ( ; i >= 0; i--) {
list.add(n / list.get(i));
}
return list;
}
}
ks2m