結果

問題 No.533 Mysterious Stairs
コンテスト
ユーザー hotchstar
提出日時 2017-08-03 19:41:33
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 725 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 262 ms
コンパイル使用メモリ 43,252 KB
最終ジャッジ日時 2026-02-22 00:08:08
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=(a);i<(n);i++)
const int MOD=(1e+9)+7;
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
ll dp[3][1000001];
int main(void)
{
	int n,i,j;
	scanf("%d",&n);
	dp[0][1]=dp[1][2]=dp[2][3]=1;
	FOR(i,3,n+1){
		FOR(j,0,3){
			dp[j][i]+=(dp[(j+1)%3][i-j-1]+dp[(j+2)%3][i-j-1])%MOD;
		}
	}
	printf("%lld\n",(dp[0][n]+dp[1][n]+dp[2][n])%MOD);
	return 0;
}
0