結果

問題 No.8 N言っちゃダメゲーム
ユーザー GrenacheGrenache
提出日時 2015-07-27 18:01:27
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 808 bytes
コンパイル時間 3,392 ms
コンパイル使用メモリ 72,192 KB
実行使用メモリ 60,584 KB
最終ジャッジ日時 2023-09-23 04:01:19
合計ジャッジ時間 10,587 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
60,584 KB
testcase_01 AC 124 ms
55,956 KB
testcase_02 AC 124 ms
55,876 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder8 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int p = sc.nextInt();
        for (int i = 0; i < p; i++) {
            int n = sc.nextInt();
            int k = sc.nextInt();
        	
        	boolean[] dp = new boolean[n + 1];
        	dp[n] = false;
        	dp[n - 1] = true;
        	for (int j = n - 2; j >= 0; j--) {
        		dp[j] = true;
        		for (int l = 1; l <= k && j + l <= n; l++) {
        			if (dp[j + l]) {
        				dp[j] = false;
        				break;
        			}
        		}
        	}

            if (!dp[0]) {
            	System.out.println("Win");
            } else {
            	System.out.println("Lose");
            }

        }

        sc.close();
    }
}
0