結果
| 問題 | No.44 DPなすごろく |
| ユーザー |
aketijyuuzou
|
| 提出日時 | 2024-10-10 21:44:15 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 5,000 ms |
| コード長 | 1,965 bytes |
| 記録 | |
| コンパイル時間 | 956 ms |
| コンパイル使用メモリ | 113,700 KB |
| 実行使用メモリ | 25,708 KB |
| 最終ジャッジ日時 | 2024-10-10 21:44:17 |
| 合計ジャッジ時間 | 2,570 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
コンパイルメッセージ
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;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("2");
//2
//2に行く方法は「1・1」と「2」の2パターンです。
}
else if (InputPattern == "Input2") {
WillReturn.Add("3");
//3
//3に行く方法は「1・1・1」と「2・1」と「1・2」の3パターンです。
//「2・1」と「1・2」は区別するのでご注意ください。
}
else if (InputPattern == "Input3") {
WillReturn.Add("5");
//8
//「1・1・1・1・1」
//「2・1・1・1」
//「1・2・1・1」
//「1・1・2・1」
//「1・1・1・2」
//「1・2・2」
//「2・1・2」
//「2・2・1」
//の8通り
}
else if (InputPattern == "Input4") {
WillReturn.Add("50");
//20365011074
//答えは 2の32乗 を超えるのでintでは収まりません。
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
int N = int.Parse(InputList[0]);
long[] PatternCntArr = new long[N + 1];
int UB = PatternCntArr.GetUpperBound(0);
PatternCntArr[1] = 1;
PatternCntArr[2] = 2;
for (int I = 3; I <= UB; I++) {
PatternCntArr[I] = PatternCntArr[I - 1] + PatternCntArr[I - 2];
}
Console.WriteLine(PatternCntArr[UB]);
}
}
aketijyuuzou