結果

問題 No.616 へんなソート
ユーザー nebukuro09nebukuro09
提出日時 2018-01-12 06:30:00
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 348 ms / 2,000 ms
コード長 864 bytes
コンパイル時間 623 ms
コンパイル使用メモリ 101,100 KB
実行使用メモリ 215,300 KB
最終ジャッジ日時 2023-09-03 18:05:29
合計ジャッジ時間 3,190 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,388 KB
testcase_12 AC 8 ms
7,240 KB
testcase_13 AC 166 ms
118,748 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 134 ms
100,052 KB
testcase_18 AC 60 ms
45,256 KB
testcase_19 AC 46 ms
34,760 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 3 ms
4,384 KB
testcase_22 AC 21 ms
18,024 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 18 ms
14,744 KB
testcase_27 AC 14 ms
12,620 KB
testcase_28 AC 348 ms
214,936 KB
testcase_29 AC 342 ms
215,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

immutable long MOD = 10^^9+7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];
    auto dp = new long[][](N+1, N*N);
    dp[1][0] = 1;

    foreach (i; 1..N) {
        foreach (j; 0..N*N-1) {
            if (dp[i][j] == 0) continue;
            dp[i+1][j] += dp[i][j];
            dp[i+1][j] %= MOD;
            dp[i+1][j+i+1] -= dp[i][j];
            dp[i+1][j+i+1] %= MOD;
        }
        foreach (j; 0..N*N-1) {
            dp[i+1][j+1] += dp[i+1][j];
            dp[i+1][j+1] %= MOD;
        }
    }

    long ans = 0;
    foreach (j; 0..K+1) (ans += dp[N][j]) %= MOD;
    ans = (ans + MOD) % MOD;
    ans.writeln;
}
0