結果

問題 No.314 ケンケンパ
ユーザー sugarrrsugarrr
提出日時 2018-03-02 13:45:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 19 ms / 1,000 ms
コード長 881 bytes
コンパイル時間 550 ms
コンパイル使用メモリ 73,664 KB
実行使用メモリ 26,760 KB
最終ジャッジ日時 2023-08-30 22:33:50
合計ジャッジ時間 1,838 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
26,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 4 ms
5,812 KB
testcase_18 AC 8 ms
14,496 KB
testcase_19 AC 14 ms
26,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


#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;
}
0