結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2018-07-03 21:13:38 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 9 ms / 1,000 ms |
コード長 | 617 bytes |
コンパイル時間 | 1,256 ms |
コンパイル使用メモリ | 160,296 KB |
実行使用メモリ | 10,856 KB |
最終ジャッジ日時 | 2024-07-01 02:01:31 |
合計ジャッジ時間 | 2,152 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define int ll typedef pair<int,int> pii; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define all(a) (a).begin(),(a).end() #define pb emplace_back #define INF (1e9+1) const ll MOD = 1e9+7; signed main(){ int n; cin>>n; if(n==1){ cout<<1<<endl; return 0; } vector<int> dp(n+1,0); dp[0] = 1; rep(i,n){ for(int step=2;step<=3;step++){ if(i+step>n)continue; (dp[i+step] += dp[i])%=MOD; } } (dp[n] += dp[n-2] + dp[n-1])%=MOD; cout<<dp[n]<<endl; }