結果

問題 No.314 ケンケンパ
ユーザー kuuso1kuuso1
提出日時 2015-12-07 00:40:23
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 90 ms / 1,000 ms
コード長 1,445 bytes
コンパイル時間 2,174 ms
コンパイル使用メモリ 104,796 KB
実行使用メモリ 33,756 KB
最終ジャッジ日時 2023-10-12 18:42:34
合計ジャッジ時間 4,312 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
31,652 KB
testcase_01 AC 54 ms
20,752 KB
testcase_02 AC 55 ms
20,884 KB
testcase_03 AC 54 ms
20,572 KB
testcase_04 AC 55 ms
20,696 KB
testcase_05 AC 55 ms
22,716 KB
testcase_06 AC 54 ms
20,644 KB
testcase_07 AC 55 ms
20,672 KB
testcase_08 AC 54 ms
20,648 KB
testcase_09 AC 55 ms
22,720 KB
testcase_10 AC 54 ms
20,780 KB
testcase_11 AC 55 ms
22,568 KB
testcase_12 AC 55 ms
20,696 KB
testcase_13 AC 55 ms
22,672 KB
testcase_14 AC 54 ms
20,704 KB
testcase_15 AC 56 ms
22,788 KB
testcase_16 AC 55 ms
20,576 KB
testcase_17 AC 57 ms
23,296 KB
testcase_18 AC 71 ms
25,816 KB
testcase_19 AC 90 ms
33,756 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[][] dp=new int[3][];
		for(int i=0;i<3;i++){
			dp[i]=new int[N+1];
		}
		
		int mod=(int)1e9+7;
		
		int pa=0;
		int ken1=1;
		int ken2=2;
		
		dp[pa][0]=1;
		for(int i=0;i<N;i++){
			dp[ken2][i+1]+=dp[ken1][i];if(dp[ken2][i+1]>=mod)dp[ken2][i+1]-=mod;
			dp[pa][i+1]+=dp[ken1][i];if(dp[pa][i+1]>=mod)dp[pa][i+1]-=mod;
			dp[pa][i+1]+=dp[ken2][i];if(dp[pa][i+1]>=mod)dp[pa][i+1]-=mod;
			dp[ken1][i+1]+=dp[pa][i];if(dp[ken1][i+1]>=mod)dp[ken1][i+1]-=mod;
		}
		
		int ans=dp[pa][N];
		ans+=dp[ken1][N];if(ans>=mod)ans-=mod;
		ans+=dp[ken2][N];if(ans>=mod)ans-=mod;
		Console.WriteLine(ans);
	}
	int N;
	public Sol(){
		N=ri();
	}




	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
0