結果

問題 No.533 Mysterious Stairs
ユーザー cureskol
提出日時 2022-12-21 15:08:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 136 ms / 5,000 ms
コード長 628 bytes
コンパイル時間 1,941 ms
コンパイル使用メモリ 199,244 KB
最終ジャッジ日時 2025-02-09 18:01:54
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)

#include <atcoder/modint>
using namespace atcoder;
using mint=modint1000000007;
ostream& operator<<(ostream &os,mint a){os<<a.val();return os;}
istream& operator>>(istream &is,mint &a){
  long long b;is>>b;a=b;
  return is;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;cin>>n;
  vector dp(n+1,vector<mint>(4,0));
  dp[0][0]=1;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=3;j++)
      REP(k,4)
        if(i-j>=0 and j!=k)
          dp[i][j]+=dp[i-j][k];
  mint ans=0;
  REP(k,4)ans+=dp[n][k];
  cout<<ans<<endl;
}
0