結果
問題 | No.2721 "Don't say N" Game |
ユーザー | tenten |
提出日時 | 2024-04-15 13:00:14 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 112 ms / 2,000 ms |
コード長 | 1,592 bytes |
コンパイル時間 | 2,614 ms |
コンパイル使用メモリ | 78,900 KB |
実行使用メモリ | 40,024 KB |
最終ジャッジ日時 | 2024-04-15 13:00:18 |
合計ジャッジ時間 | 4,242 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 60 ms
37,156 KB |
testcase_01 | AC | 104 ms
39,296 KB |
testcase_02 | AC | 112 ms
39,472 KB |
testcase_03 | AC | 106 ms
40,024 KB |
testcase_04 | AC | 88 ms
38,108 KB |
testcase_05 | AC | 105 ms
39,376 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); String[] ans = {"K", "P"}; int t = sc.nextInt(); StringBuilder sb = new StringBuilder(); while (t-- > 0) { int n = sc.nextInt(); Set<Integer> counts = new HashSet<>(); for (int i = 1; i <= Math.sqrt(n); i++) { if (n % i == 0) { counts.add(i); counts.add(n / i); } } sb.append(ans[counts.size() % 2]).append("\n"); } System.out.print(sb); } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }