結果

問題 No.2721 "Don't say N" Game
ユーザー ks2mks2m
提出日時 2024-04-12 21:35:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 248 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 5,629 ms
コンパイル使用メモリ 75,304 KB
実行使用メモリ 57,212 KB
最終ジャッジ日時 2024-04-12 21:35:32
合計ジャッジ時間 7,983 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
54,252 KB
testcase_01 AC 245 ms
55,208 KB
testcase_02 AC 243 ms
54,916 KB
testcase_03 AC 248 ms
57,212 KB
testcase_04 AC 216 ms
54,576 KB
testcase_05 AC 239 ms
55,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
	}
}
0