結果

問題 No.372 It's automatic
ユーザー 紙ぺーぱー紙ぺーぱー
提出日時 2016-05-14 01:45:01
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 3,973 ms / 6,000 ms
コード長 1,476 bytes
コンパイル時間 846 ms
コンパイル使用メモリ 110,416 KB
実行使用メモリ 35,396 KB
最終ジャッジ日時 2024-04-15 19:04:34
合計ジャッジ時間 50,306 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
17,408 KB
testcase_01 AC 23 ms
17,664 KB
testcase_02 AC 24 ms
17,536 KB
testcase_03 AC 24 ms
17,536 KB
testcase_04 AC 3,925 ms
35,260 KB
testcase_05 AC 3,937 ms
35,396 KB
testcase_06 AC 3,921 ms
35,304 KB
testcase_07 AC 3,946 ms
35,324 KB
testcase_08 AC 3,959 ms
35,000 KB
testcase_09 AC 3,936 ms
35,316 KB
testcase_10 AC 3,940 ms
35,264 KB
testcase_11 AC 3,896 ms
35,396 KB
testcase_12 AC 3,973 ms
35,252 KB
testcase_13 AC 3,916 ms
35,276 KB
testcase_14 AC 3,948 ms
35,240 KB
testcase_15 AC 3,957 ms
35,120 KB
testcase_16 AC 25 ms
17,664 KB
testcase_17 AC 25 ms
17,536 KB
testcase_18 AC 24 ms
17,664 KB
testcase_19 AC 24 ms
17,280 KB
testcase_20 AC 24 ms
17,664 KB
testcase_21 AC 200 ms
21,376 KB
testcase_22 AC 201 ms
21,632 KB
testcase_23 AC 198 ms
21,888 KB
testcase_24 AC 199 ms
21,632 KB
testcase_25 AC 198 ms
21,760 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using StringBuilder = System.Text.StringBuilder;
using System.Numerics;
using Number = System.Int64;
using Point = System.Numerics.Complex;
namespace Program
{
    public class Solver
    {
        static void Main()
        {
            var s = Console.ReadLine();
            var m = int.Parse(Console.ReadLine());
            var n = s.Length;
            var dp = new int[m];
            int ans = 0;
            var to = new int[10][];
            for (int i = 0; i < 10; i++)
            {
                to[i] = new int[m];
                for (int j = 0; j < m; j++)
                    to[i][j] = (j * 10 + i) % m;
            }
            const int MOD = 1000000007;
            for (int i = 0; i < n; i++)
            {
                var v = s[i] - '0';
                var next = new int[m];
                Buffer.BlockCopy(dp, 0, next, 0, sizeof(int) * m);
                if (v > 0) next[v % m]++;
                else ans += 1;
                for (int j = 0; j < m; j++)
                {
                    next[to[v][j]] += dp[j];
                    if (next[to[v][j]] >= MOD) next[to[v][j]] -= MOD;
                }
                dp = next;
            }
            Console.WriteLine((dp[0] + ans) % MOD);


        }

        static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
    }
}
0