結果
| 問題 |
No.41 貯金箱の溜息(EASY)
|
| コンテスト | |
| ユーザー |
14番
|
| 提出日時 | 2016-06-12 04:01:56 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,304 bytes |
| コンパイル時間 | 2,125 ms |
| コンパイル使用メモリ | 107,136 KB |
| 実行使用メモリ | 328,888 KB |
| 最終ジャッジ日時 | 2024-10-09 13:02:18 |
| 合計ジャッジ時間 | 10,663 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 TLE * 1 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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();
}
}
14番