結果
問題 |
No.287 場合の数
|
ユーザー |
![]() |
提出日時 | 2016-05-15 00:49:33 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 38 ms / 5,000 ms |
コード長 | 2,096 bytes |
コンパイル時間 | 908 ms |
コンパイル使用メモリ | 105,472 KB |
実行使用メモリ | 18,048 KB |
最終ジャッジ日時 | 2024-11-08 00:16:53 |
合計ジャッジ時間 | 2,607 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
コンパイルメッセージ
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.targetNum = int.Parse(Reader.ReadLine()); ulong ans = this.GetAns(0, targetNum * 6); Console.WriteLine(ans); } private int targetNum = 0; private Dictionary<int, Dictionary<int, ulong>> dic = new Dictionary<int, Dictionary<int, ulong>>(); private ulong GetAns(int idx, int remain) { if (!dic.ContainsKey(idx)) { dic.Add(idx, new Dictionary<int, ulong>()); } if (dic[idx].ContainsKey(remain)) { return dic[idx][remain]; } if (remain == 0) { return 1; } if (remain < 0) { return 0; } if (idx == 7) { if (remain <= this.targetNum) { return 1; } else { return 0; } } if ((8 - idx) * targetNum < remain) { return 0; } if ((8 - idx) * targetNum == remain) { return 1; } ulong ans = 0; for (int i = 0; i <= targetNum; i++) { ans += this.GetAns(idx+1, remain - i); } this.dic[idx].Add(remain, ans); return ans; } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 100 "; 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(); } }