結果
問題 | No.189 SUPER HAPPY DAY |
ユーザー |
![]() |
提出日時 | 2015-04-18 02:54:56 |
言語 | C# (csc 3.6.0) |
結果 |
AC
|
実行時間 | 329 ms / 5,000 ms |
コード長 | 2,132 Byte |
コンパイル時間 | 2,009 ms |
使用メモリ | 29,240 KB |
最終ジャッジ日時 | 2020-09-29 22:52:13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
18,500 KB |
testcase_01 | AC | 35 ms
18,472 KB |
testcase_02 | AC | 35 ms
18,380 KB |
testcase_03 | AC | 35 ms
18,380 KB |
testcase_04 | AC | 34 ms
18,668 KB |
testcase_05 | AC | 35 ms
18,456 KB |
testcase_06 | AC | 35 ms
18,596 KB |
testcase_07 | AC | 35 ms
18,624 KB |
testcase_08 | AC | 35 ms
18,388 KB |
testcase_09 | AC | 35 ms
18,384 KB |
testcase_10 | AC | 34 ms
18,492 KB |
testcase_11 | AC | 33 ms
18,384 KB |
testcase_12 | AC | 33 ms
18,524 KB |
testcase_13 | AC | 134 ms
20,328 KB |
testcase_14 | AC | 180 ms
21,592 KB |
testcase_15 | AC | 194 ms
22,320 KB |
testcase_16 | AC | 217 ms
23,344 KB |
testcase_17 | AC | 230 ms
23,500 KB |
testcase_18 | AC | 183 ms
21,776 KB |
testcase_19 | AC | 243 ms
23,708 KB |
testcase_20 | AC | 86 ms
19,260 KB |
testcase_21 | AC | 82 ms
19,216 KB |
testcase_22 | AC | 36 ms
18,380 KB |
testcase_23 | AC | 175 ms
23,568 KB |
testcase_24 | AC | 187 ms
23,244 KB |
testcase_25 | AC | 329 ms
29,240 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.6.0-4.20224.5 (ec77c100) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; using System.Numerics; static public class Program { static public void Main() { var max = BigInteger.Pow(10, 200); const long mod = (long)1e9 + 9; var S = readString(2).ValidateArray(x => { var v = BigInteger.Parse(x); return 1 <= v && v <= max; }); readEOF(); var a = func(S[0]); var b = func(S[1]); long ans = 0; for (int i = 1; i < Math.Min(a.Length, b.Length); i++) ans = (ans + a[i] * b[i]) % mod; Console.WriteLine(ans); } static long[] func(string str) { const long mod = (long)1e9 + 9; var len = str.Length; var max = len * 9; var dp = new long[2, len + 1, max + 10]; dp[1, 0, 0] = 1; for (int i = 0; i < len; i++) for (int j = 0; j <= max; j++) for (int k = 0; k < 10; k++) { if (k == str[i] - '0') dp[1, i + 1, j + k] = (dp[1, i + 1, j + k] + dp[1, i, j]) % mod; else if (k < str[i] - '0') dp[0, i + 1, j + k] = (dp[0, i + 1, j + k] + dp[1, i, j]) % mod; dp[0, i + 1, j + k] = (dp[0, i + 1, j + k] + dp[0, i, j]) % mod; } var ret = new long[max + 10]; for (int i = 0; i <= max; i++) ret[i] = (dp[0, len, i] + dp[1, len, i]) % mod; return ret; } static string[] readString(int n) { var s = Console.ReadLine().Split(' '); if (s.Length != n) throw new Exception(string.Format("invalid input, expected{0} actual{1}", n, s.Length)); return s; } static void readEOF() { if (Console.In.Peek() >= 0) throw new Exception("invalid input too long input file"); } } static public class Ex { static public T[] ValidateArray<T>(this T[] input, Func<T, bool> f) { foreach (var x in input) if (!f(x)) throw new Exception("invalid input"); return input; } }