結果

問題 No.53 悪の漸化式
ユーザー HiroakiSoftwareHiroakiSoftware
提出日時 2014-10-31 00:13:33
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,094 bytes
コンパイル時間 4,649 ms
コンパイル使用メモリ 104,924 KB
実行使用メモリ 22,908 KB
最終ジャッジ日時 2023-08-28 23:33:12
合計ジャッジ時間 4,112 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
20,820 KB
testcase_01 AC 55 ms
20,760 KB
testcase_02 AC 59 ms
20,812 KB
testcase_03 AC 58 ms
20,744 KB
testcase_04 AC 58 ms
22,804 KB
testcase_05 AC 58 ms
20,736 KB
testcase_06 AC 58 ms
20,940 KB
testcase_07 AC 60 ms
20,752 KB
testcase_08 AC 58 ms
20,688 KB
testcase_09 AC 58 ms
20,852 KB
testcase_10 AC 56 ms
20,756 KB
testcase_11 AC 59 ms
22,868 KB
testcase_12 AC 58 ms
20,864 KB
testcase_13 AC 60 ms
22,800 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Threading.Tasks;

namespace yc53cs
{
    class Program
    {
        static Decimal[] Cache = new Decimal[99];
        static bool[] bWroteCache = new bool[99];
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            for (int i = 0; i < Cache.Length; i++)
            {
                Cache[i] = 0;
                bWroteCache[i] = false;

            }

            Console.WriteLine(Calc(N));
        }

        static Decimal Calc(int k)
        {
            if (k == 0)
            {
                return 4;
            }
            else if (k == 1)
            {
                return 3;
            }
            else
            {
                if (bWroteCache[k - 2]) return Cache[k - 2];
                Cache[k - 2] = (19 * Calc(k - 1) - 12 * Calc(k - 2)) / 4;
                bWroteCache[k - 2] = true;
                return Cache[k - 2];
            }
        }
    }
}
0