結果
問題 |
No.372 It's automatic
|
ユーザー |
![]() |
提出日時 | 2016-05-14 02:20:37 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 2,765 ms / 6,000 ms |
コード長 | 1,458 bytes |
コンパイル時間 | 837 ms |
コンパイル使用メモリ | 112,152 KB |
実行使用メモリ | 18,688 KB |
最終ジャッジ日時 | 2024-10-05 21:51:44 |
合計ジャッジ時間 | 35,436 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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 uint[32768]; var next = new uint[32768]; var ans = 0u; var to = new int[10][]; for (int i = 0; i < 10; i++) { to[i] = new int[32768]; for (int j = 0; j < m; j++) to[i][j] = (j * 10 + i) % m; } const int MOD = 1000000007; foreach (var x in s) { var v = x - '0'; Buffer.BlockCopy(dp, 0, next, 0, sizeof(uint) * 32768); if (v > 0) next[v % m]++; else ans++; for (int j = 0; j < m; j++) { if ((next[to[v][j]] += dp[j]) >= MOD) next[to[v][j]] -= MOD; } Swap(ref dp, ref 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; } } }