結果

問題 No.1521 Playing Musical Chairs Alone
ユーザー tentententen
提出日時 2021-06-01 12:13:05
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,092 bytes
コンパイル時間 2,248 ms
コンパイル使用メモリ 78,528 KB
実行使用メモリ 41,484 KB
最終ジャッジ日時 2024-04-26 09:47:35
合計ジャッジ時間 6,636 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
36,940 KB
testcase_01 AC 53 ms
37,048 KB
testcase_02 AC 54 ms
37,128 KB
testcase_03 AC 52 ms
37,056 KB
testcase_04 AC 55 ms
36,672 KB
testcase_05 WA -
testcase_06 AC 139 ms
40,488 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 51 ms
37,116 KB
testcase_13 AC 52 ms
37,068 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 203 ms
41,364 KB
testcase_23 WA -
testcase_24 AC 207 ms
41,128 KB
testcase_25 AC 206 ms
41,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    static final int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int k = sc.nextInt();
        int m = sc.nextInt();
        long[][][]  array = new long[20][n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                array[0][i][(i + j + 1) % n]++;
            }
        }
        for (int a = 1; a < 20; a++) {
            for (int b = 0; b < n; b++) {
                for (int c = 0; c < n; c++) {
                    for (int d = 0; d < n; d++) {
                        array[a][b][c] += array[a - 1][d][c] * array[a - 1][b][d] % MOD;
                        array[a][b][c] %= MOD;
                    }
                }
            }
        }
        long[] ans = new long[n];
        ans[0] = 1;
        for (int i = 19; i >= 0; i--) {
            if (k < (1 <<  i)) {
                continue; 
            }
            k -= 1 << i;
            long[] next = new long[n];
            for (int a = 0; a < n; a++) {
                for (int b = 0; b < n; b++) {
                    next[a] += ans[b] * array[i][a][b] % MOD;
                    next[a] %= MOD;
                }
            }
            ans = next;
        }
        StringBuilder sb = new StringBuilder();
        for (long x : ans) {
            sb.append(x).append("\n");
        }
        System.out.print(sb);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0