結果

問題 No.8 N言っちゃダメゲーム
ユーザー tentententen
提出日時 2023-02-14 13:11:24
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 2,113 bytes
コンパイル時間 2,538 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 56,308 KB
最終ジャッジ日時 2023-09-24 03:03:47
合計ジャッジ時間 9,678 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
53,884 KB
testcase_01 AC 44 ms
49,620 KB
testcase_02 AC 44 ms
49,564 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int p = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        while (p-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            boolean[] canWin = new boolean[n + 1];
            canWin[0] = true;
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= k && j <= i; j++) {
                    if (!canWin[i - j]) {
                        canWin[i] = true;
                        break;
                    }
                }
            }
            if (canWin[n]) {
                sb.append("Win\n");
            } else {
                sb.append("Lose\n");
            }
        }
        System.out.print(sb);
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0