結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
![]() |
提出日時 | 2016-08-11 00:08:16 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 20 ms / 5,000 ms |
コード長 | 1,061 bytes |
コンパイル時間 | 841 ms |
コンパイル使用メモリ | 103,552 KB |
実行使用メモリ | 18,304 KB |
最終ジャッジ日時 | 2024-06-12 03:39:40 |
合計ジャッジ時間 | 1,829 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
import std.stdio;import std.string;import std.array;import std.typecons;import std.typetuple;import std.container;import std.algorithm;import std.conv;import std.math;import std.format;alias TypeTuple tie;void readlnToken(T...)(auto ref T args){import std.stdio;import std.conv;import std.string;import std.array;auto line = split(readln().strip);foreach(ref arg; args){arg = to!(typeof(arg))(line[0]);line = line[1..$];}assert(line.empty()); // got all token??}const Mod = cast(long)(1E+9)+7;void solve(){int N,S,K;readlnToken(N,S,K);S -= N*(N-1)/2 * K;if (S < 0){writeln(0);return;}auto dp = new long[][](N+1,S+1);dp[0][0] = 1;foreach(i;1..N+1){foreach(j;0..S+1){dp[i][j] = dp[i-1][j] % Mod;int k = j - (N-i+1);if (k >= 0)(dp[i][j] += dp[i][k] % Mod) %= Mod;}}writeln(dp[N][S]);}void main(){solve();}