結果

問題 No.189 SUPER HAPPY DAY
ユーザー mban
提出日時 2017-09-23 10:26:58
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 171 ms / 5,000 ms
コード長 1,459 bytes
コンパイル時間 1,046 ms
コンパイル使用メモリ 112,264 KB
実行使用メモリ 32,700 KB
最終ジャッジ日時 2024-11-14 03:57:18
合計ジャッジ時間 3,174 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    readonly int Max=2000;
    readonly int Mod=1000000009;
    private long[]Calc(string s)
    {
        var dp1=new long[Max,s.Length+1];
        var dp2=new long[Max,s.Length+1];
        dp1[0,0]=1;
        dp2[0,0]=1;
        for(int i=1;i<=s.Length;i++)
        {
            int index=s.Length-i;
            for(int k=0;k<=9*(i-1);k++)
            {
                for(int j=0;j<=9;j++)
                {
                    dp1[k+j,i]+=dp1[k,i-1];
                    if(s[index]-'0'==j)
                    {
                        dp2[k+j,i]+=dp2[k,i-1];
                    }
                    else if(s[index]-'0'>j)
                    {
                        dp2[k+j,i]+=dp1[k,i-1];
                    }
                    dp1[k+j,i]%=Mod;
                    dp2[k+j,i]%=Mod;
                }
            }
        }
        var res=new long[Max];
        for(int i=0;i<Max;i++)
        {
            res[i]=dp2[i,s.Length];
        }
        return res;
    }
    
    public void Solve()
    {
        var l=Console.ReadLine().Split(' ');
        var m=Calc(l[0]);
        var d=Calc(l[1]);
        long ans=0;
        for(int i=1;i<Max;i++)
        {
            ans+=(m[i]*d[i])%Mod;
            ans%=Mod;
        }
        Console.WriteLine(ans);
    } 
    
    static void Main()
    {
        new Program().Solve();
    }
}
0