結果
| 問題 |
No.53 悪の漸化式
|
| コンテスト | |
| ユーザー |
HiroakiSoftware
|
| 提出日時 | 2014-10-31 00:13:33 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,094 bytes |
| コンパイル時間 | 1,195 ms |
| コンパイル使用メモリ | 104,192 KB |
| 実行使用メモリ | 18,176 KB |
| 最終ジャッジ日時 | 2024-12-30 14:49:21 |
| 合計ジャッジ時間 | 2,684 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 6 |
コンパイルメッセージ
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.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];
}
}
}
}
HiroakiSoftware