結果
問題 | No.7 プライムナンバーゲーム |
ユーザー | takeya_okino |
提出日時 | 2019-09-14 23:01:28 |
言語 | Java19 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 559 bytes |
コンパイル時間 | 2,276 ms |
コンパイル使用メモリ | 71,728 KB |
実行使用メモリ | 56,596 KB |
最終ジャッジ日時 | 2023-09-21 01:07:42 |
合計ジャッジ時間 | 6,754 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 368 ms
55,764 KB |
testcase_03 | AC | 145 ms
55,952 KB |
testcase_04 | WA | - |
testcase_05 | AC | 133 ms
55,796 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 229 ms
56,104 KB |
testcase_10 | AC | 124 ms
56,032 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 363 ms
55,648 KB |
testcase_15 | AC | 354 ms
55,816 KB |
testcase_16 | WA | - |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] dp = new int[n + 1]; for(int i = 2; i < n + 1; i++) { int p = 0; int m = i; for(int j = 2; j < i - 1; j++) { if((m % j) == 0) { if(dp[i - j] == 0) p++; while((m % j) == 0) { m /= j; } } } if(p > 0) dp[i] = 1; } String ans = "Win"; if(dp[n] == 0) ans = "Lose"; System.out.println(ans); } }