結果

問題 No.533 Mysterious Stairs
ユーザー nenuonnenuon
提出日時 2017-06-23 22:59:51
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 37 ms / 5,000 ms
コード長 773 bytes
コンパイル時間 836 ms
コンパイル使用メモリ 93,600 KB
実行使用メモリ 34,644 KB
最終ジャッジ日時 2024-10-04 07:48:17
合計ジャッジ時間 1,966 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
const long long MOD = 1000000007;
long long dp[1000000][4];
int main(){
  long long n;
  cin >> n;
  FOR(i,0,n+1){
    FOR(j,0,4){
      dp[i][j] = 0;
    }
  }
  dp[0][0] = 1;
  FOR(i,1,n+1){
    FOR(j,1,4){
      FOR(k,0,4){
        if(j == k) continue;
        if(i - j < 0) continue;
        dp[i][j] += dp[i-j][k];
        dp[i][j] %= MOD;
      }
    }
  }
  cout << (dp[n][1]+dp[n][2]+dp[n][3]) % MOD << endl;
  return 0;
}
0