結果

問題 No.314 ケンケンパ
ユーザー NaruYNaruY
提出日時 2018-05-09 09:34:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 1,000 ms
コード長 1,099 bytes
コンパイル時間 2,312 ms
コンパイル使用メモリ 164,468 KB
実行使用メモリ 34,836 KB
最終ジャッジ日時 2023-09-10 11:15:30
合計ジャッジ時間 2,702 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
34,836 KB
testcase_01 AC 3 ms
9,648 KB
testcase_02 AC 3 ms
9,608 KB
testcase_03 AC 3 ms
9,584 KB
testcase_04 AC 3 ms
9,712 KB
testcase_05 AC 3 ms
9,868 KB
testcase_06 AC 2 ms
9,592 KB
testcase_07 AC 3 ms
9,656 KB
testcase_08 AC 3 ms
9,668 KB
testcase_09 AC 3 ms
9,568 KB
testcase_10 AC 3 ms
9,608 KB
testcase_11 AC 3 ms
9,584 KB
testcase_12 AC 3 ms
9,676 KB
testcase_13 AC 2 ms
9,608 KB
testcase_14 AC 3 ms
9,604 KB
testcase_15 AC 3 ms
9,672 KB
testcase_16 AC 3 ms
9,848 KB
testcase_17 AC 5 ms
14,476 KB
testcase_18 AC 9 ms
25,944 KB
testcase_19 AC 14 ms
34,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);i++)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long ll;
//////////////////////////////////////////////////////
int main(){
	const ll p = 1000000007;
	int N; SCD(N);
	static ll dp[1000002];
	static ll kk[1000002];
	static ll kp[1000002];
	static ll pk[1000002];
	
	dp[1] = 1;
	dp[2] = 2;
	dp[3] = 2;
	
	kk[3] = 0;
	pk[3] = 1;
	kp[3] = 1;
	
	FORq(i,4,N){
		dp[i] = (dp[i-1] + pk[i-1]) % p;
		
		kp[i] = (kk[i-1] + pk[i-1]) % p;
		pk[i] = kp[i-1] % p;
		kk[i] = pk[i-1] % p;
		
	}
	
	PRINTLLD(dp[N]);
	
	return 0;
}
0