結果
問題 | No.533 Mysterious Stairs |
ユーザー |
|
提出日時 | 2018-10-17 02:25:58 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 169 ms / 5,000 ms |
コード長 | 819 bytes |
コンパイル時間 | 706 ms |
コンパイル使用メモリ | 102,912 KB |
実行使用メモリ | 51,432 KB |
最終ジャッジ日時 | 2024-06-13 01:53:00 |
合計ジャッジ時間 | 5,857 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
ソースコード
import std.stdio;import std.algorithm;import std.range;import std.conv;import std.format;import std.array;import std.math;import std.string;import std.container;void main() {int N; readlnTo(N);auto dp = new int[][](1000001, 4);const int mod = 1000000007;dp[0][0] = 1;int val;foreach(i; 0..N) {foreach(j; 1..4) {if (i + j > N)continue;val = dp[i+j][j];foreach(k; 0..4) {if (j == k)continue;val = (val + dp[i][k]) % mod;}dp[i+j][j] = val;}}int ans = 0;foreach(i; 1..4)ans = (ans + dp[N][i]) % mod;ans.writeln;}// helpersvoid readlnTo(T...)(ref T t) {auto s = readln.split;assert(s.length == t.length);foreach(ref ti; t) {ti = s[0].to!(typeof(ti));s = s[1..$];}}