結果
| 問題 |
No.314 ケンケンパ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-08-28 16:55:34 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 85 ms / 1,000 ms |
| コード長 | 597 bytes |
| コンパイル時間 | 812 ms |
| コンパイル使用メモリ | 107,368 KB |
| 実行使用メモリ | 50,240 KB |
| 最終ジャッジ日時 | 2024-11-14 06:21:48 |
| 合計ジャッジ時間 | 2,124 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
class KenKenPa2
{
const int M = 1000000007;
static int N;
static void Main(String[] args)
{
N = int.Parse(Console.ReadLine());
if(N == 1)
{
Console.WriteLine(1);
return;
}
if(N == 2)
{
Console.WriteLine(2);
return;
}
long[,,] dp = new long[2,2,N+1];
dp[0,0,N] = 1;
dp[0,1,N] = 1;
dp[1,0,N] = 1;
for(int i=N-1; i>=2; i--)
{
dp[0,0,i] = dp[1,0,i+1];
dp[0,1,i] = (dp[0,0,i+1] + dp[1,0,i+1]) % M;
dp[1,0,i] = dp[0,1,i+1];
}
dp[0,0,1] = (dp[1,0,2] + dp[0,0,2]) % M;
dp[0,0,0] = dp[0,0,1];
Console.WriteLine(dp[0,0,0]);
}
}