結果
問題 | No.616 へんなソート |
ユーザー |
|
提出日時 | 2018-01-12 06:30:00 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 301 ms / 2,000 ms |
コード長 | 864 bytes |
コンパイル時間 | 965 ms |
コンパイル使用メモリ | 117,064 KB |
実行使用メモリ | 214,316 KB |
最終ジャッジ日時 | 2024-06-12 23:30:31 |
合計ジャッジ時間 | 2,757 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
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; }