結果
| 問題 |
No.314 ケンケンパ
|
| コンテスト | |
| ユーザー |
yukkuriesu
|
| 提出日時 | 2018-12-05 23:46:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 1,000 ms |
| コード長 | 1,478 bytes |
| コンパイル時間 | 1,322 ms |
| コンパイル使用メモリ | 158,496 KB |
| 実行使用メモリ | 26,768 KB |
| 最終ジャッジ日時 | 2024-07-22 06:58:59 |
| 合計ジャッジ時間 | 1,889 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) repf(i,0,N)
#define reps(i,N) repfs(i,0,N)
#define repf(i,a,b) for(int i=a;i<b;i++)
#define repfs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)
#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<"."
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<"."
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"."
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d<<"."
#define da(arr,N){if(isDebugMode){rep(i,N){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N){rep(j,M){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back
auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 1000000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};
bool isDebugMode=1;
//--------------------------------------//
int n;
ll dp[1000000][3];
void solve(){
dp[0][1]=1;
rep(i,n-1){
dp[i+1][0]=(dp[i][1]+dp[i][2])%MOD;
dp[i+1][1]=dp[i][0];
dp[i+1][2]=dp[i][1];
}
ll ans=0;
rep(i,3){
ans+=dp[n-1][i];
}
cout<<ans%MOD<<endl;
}
int main(){
cin>>n;
solve();
return 0;
}
yukkuriesu