結果
| 問題 |
No.533 Mysterious Stairs
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-08-03 19:41:33 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 21 ms / 5,000 ms |
| コード長 | 725 bytes |
| コンパイル時間 | 222 ms |
| コンパイル使用メモリ | 31,744 KB |
| 実行使用メモリ | 25,344 KB |
| 最終ジャッジ日時 | 2024-10-11 20:31:12 |
| 合計ジャッジ時間 | 1,250 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 28 |
ソースコード
#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;
}