結果
問題 |
No.314 ケンケンパ
|
ユーザー |
![]() |
提出日時 | 2018-03-02 13:45:22 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 24 ms / 1,000 ms |
コード長 | 881 bytes |
コンパイル時間 | 1,033 ms |
コンパイル使用メモリ | 83,148 KB |
実行使用メモリ | 26,880 KB |
最終ジャッジ日時 | 2025-01-02 20:52:13 |
合計ジャッジ時間 | 1,770 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h> #include<stack> #include<queue> #include<vector> #include<algorithm> #include<string> #include<iostream> #include<set> #include<map> #include<bitset> using namespace std; typedef long long ll; #define i_7 1000000007 #define i_5 1000000005 ll mod(ll a){ ll c=a%i_7; if(c>=0)return c; else return c+i_7; } typedef pair<int,int> i_i; typedef pair<ll,ll> l_l; #define inf 100000000/*10^8*/ #define rep(i,l,r) for(int i=l;i<=r;i++) const double EPS=1E-8; //////////////////////////////////////// int main(){ int n;cin>>n; ll dp[3][n+1];dp[0][1]=0;dp[1][1]=1;dp[2][1]=0; rep(i,2,n){ dp[0][i]=mod(dp[2][i-1]+dp[1][i-1]); dp[1][i]=mod(dp[0][i-1]); dp[2][i]=mod(dp[1][i-1]); } ll ans=0; rep(i,0,2)ans=mod(ans+dp[i][n]); cout<<ans; return 0; }