結果

問題 No.533 Mysterious Stairs
ユーザー 777yuuki12323
提出日時 2017-06-26 17:40:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 33 ms / 5,000 ms
コード長 887 bytes
コンパイル時間 516 ms
コンパイル使用メモリ 72,116 KB
実行使用メモリ 35,376 KB
最終ジャッジ日時 2024-10-04 09:40:25
合計ジャッジ時間 1,474 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>


typedef long long ll;
#define fi first
#define se second
const ll mod = 1000000007;
//              123456789

using namespace std;

///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
ll cost[1234567][4];
ll ans = 0;


int main(){
	
	cin>>N;
	
	fill( cost[0], cost[N], 0 );
	
	cost[0][0] = 1;
	
	int i;
	int j;
	int k;
	
	for( i = 0; i <= N; i++ ){
		for( j = 0; j < 4; j++ ){
			for( k = 1; k < 4; k++ ){
				if( k != j ){
					(cost[i+k][k] += cost[i][j])%=mod;
				}
			}
		}
	}
	
	for( i = 1; i < 4; i++ ){
		(ans += cost[N][i])%=mod;
	}
	
	cout<<ans<<endl;
	
}
0