結果
問題 |
No.314 ケンケンパ
|
ユーザー |
![]() |
提出日時 | 2018-06-16 01:18:34 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 36 ms / 1,000 ms |
コード長 | 749 bytes |
コンパイル時間 | 1,530 ms |
コンパイル使用メモリ | 165,572 KB |
実行使用メモリ | 27,008 KB |
最終ジャッジ日時 | 2024-06-30 15:51:45 |
合計ジャッジ時間 | 2,466 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include "bits/stdc++.h" #define REP(i,n,N) for(ll i=(n); i<(N); i++) #define RREP(i,n,N) for(ll i=(N-1); i>=n; i--) #define CK(n,a,b) (a)<=(n)&&(n)<(b) #define ALL(v) (v).begin(),(v).end() #define p(s) cout<<(s)<<endl typedef long long ll; using namespace std; const ll mod =1e9+7; ll N; ll dp[1000010][3]; ll ans; int main(){ scanf("%lld", &N); dp[0][0]=1; REP(i,0,N){ REP(j,0,3){ if(j<2){ dp[i+1][j+1] += dp[i][j]; dp[i+1][j+1]%=mod; } if(j>0) { dp[i+1][0] += dp[i][j]; dp[i+1][0]%=mod; } } } REP(j,0,3){ ans += dp[N][j]; ans%=mod; } printf("%lld\n", ans); return 0; }