結果

問題 No.41 貯金箱の溜息(EASY)
ユーザー 14番14番
提出日時 2016-06-12 04:01:56
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 2,304 bytes
コンパイル時間 2,408 ms
コンパイル使用メモリ 115,608 KB
実行使用メモリ 506,740 KB
最終ジャッジ日時 2024-04-17 18:56:00
合計ジャッジ時間 11,091 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,183 ms
133,828 KB
testcase_01 TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        this.Init();
        int inputCount = int.Parse(Reader.ReadLine());
        for(int i=0; i<inputCount; i++) {
            this.GetAns(long.Parse(Reader.ReadLine()));
        }
    }

    private void GetAns(long num) {
        long ans =this.GetAnsSub(0, num);
        Console.WriteLine(ans);
    }

    Dictionary<long, long>[] dic = new Dictionary<long, long>[9];

    private long GetAnsSub(int idx, long remain) {
        if(this.dic[idx] == null) {
            this.dic[idx] = new Dictionary<long, long>();
        }
        if(this.dic[idx].ContainsKey(remain)) {
            return dic[idx][remain];
        }
        if(remain == 0) {
            return 1;
        }
        if(remain < this.CoinList.Last()) {
            return 1;
        }
        long ans = 1;
        for(int i=idx; i<this.CoinList.Count; i++) {
            if(this.CoinList[i] > remain) {
                continue;
            }
            long ret = this.GetAnsSub(i, remain - this.CoinList[i]);
            ans += ret % ModNum;;
        }
        ans = ans % ModNum;
        this.dic[idx].Add(remain, ans);
        return ans;

    }
    private long ModNum = 1000000000 + 9;

    private List<long> CoinList = new List<long>();
    private void Init() {
        long[] dat = new long[]{111111,222222,333333,444444,555555,666666,777777,888888,999999};
        CoinList.AddRange(dat);
        this.CoinList.Reverse();
    }



    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"


7
1
111112
222222
10000000
100000000
1000000000
10000000000



";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}
0