結果

問題 No.7 プライムナンバーゲーム
ユーザー holegumaholeguma
提出日時 2015-07-26 03:58:15
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 622 bytes
コンパイル時間 1,958 ms
コンパイル使用メモリ 75,740 KB
実行使用メモリ 51,608 KB
最終ジャッジ日時 2023-09-22 23:22:47
合計ジャッジ時間 4,524 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 41 ms
49,220 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 55 ms
51,412 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 105 ms
51,192 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 183 ms
51,380 KB
testcase_15 AC 174 ms
51,412 KB
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.Arrays;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
boolean[] p=new boolean[10001];
Arrays.fill(p,true);
p[0]=false;
p[1]=false;
for(int i=2;i<=Math.sqrt(10000);i++){
if(p[i]){
for(int j=i+i;j<=10000;j+=i){
p[j]=false;
}
}
}
while((line=br.readLine())!=null){
int n=Integer.parseInt(line);
int[] dp=new int[10001];
dp[0]=0;
dp[1]=0;
for(int i=2;i<=n;i++){
for(int j=2;j<=i;j++){
if(p[i-j]&&dp[j]==1){
dp[i]=1;
break;
}
}
}
System.out.println(dp[n]==1?"Win":"Lose");
}
}
}
0