結果
問題 |
No.260 世界のなんとか3
|
ユーザー |
|
提出日時 | 2016-11-22 18:39:22 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,091 bytes |
コンパイル時間 | 1,838 ms |
コンパイル使用メモリ | 154,468 KB |
実行使用メモリ | 21,188 KB |
最終ジャッジ日時 | 2024-06-12 05:12:16 |
合計ジャッジ時間 | 11,550 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 27 |
ソースコード
import std.stdio; import std.array; import std.string; import std.conv; import std.algorithm; import std.typecons; import std.range; import std.random; import std.math; import std.container; import std.numeric; long mod = 10L^^9+7; long solve(string S) { auto N = S.length; auto dp = new long[][][][][](N+1, 2, 3, 2, 8); // keta, miman, 3wareru, 3tsuku, 8wareru dp[0][0][0][0][0] = 1; foreach (i; 0..N) foreach (j; 0..2) foreach (k; 0..3) foreach (l; 0..2) foreach (m; 0..8) { auto digit = j ? 9 : (S[i]-'0').to!int; foreach (d; 0..digit+1) (dp[i+1][j||(d<digit)][(k+d)%3][l||(d==3)][(m+d)%8] += dp[i][j][k][l][m]) %= mod; } long ans = 0; foreach (k; 0..3) foreach (l; 0..2) foreach(m; 0..8) if ((k == 0 || l > 0) && m > 0) (ans += dp[N][1][k][l][m]) %= mod; writeln(dp); return ans; } void main() { auto input = readln.split; auto A = input[0]; auto B = input[1]; writeln(solve(B)); //writeln(solve(A)); //writeln(solve(B)-solve(A)); }