結果

問題 No.314 ケンケンパ
ユーザー albicillaalbicilla
提出日時 2015-12-08 15:36:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 15 ms / 1,000 ms
コード長 1,522 bytes
コンパイル時間 1,135 ms
コンパイル使用メモリ 144,328 KB
実行使用メモリ 26,756 KB
最終ジャッジ日時 2023-10-12 21:54:17
合計ジャッジ時間 2,151 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
26,656 KB
testcase_01 AC 3 ms
7,412 KB
testcase_02 AC 2 ms
7,396 KB
testcase_03 AC 2 ms
7,444 KB
testcase_04 AC 2 ms
7,448 KB
testcase_05 AC 2 ms
7,448 KB
testcase_06 AC 3 ms
7,448 KB
testcase_07 AC 2 ms
7,448 KB
testcase_08 AC 2 ms
7,408 KB
testcase_09 AC 2 ms
7,472 KB
testcase_10 AC 2 ms
7,560 KB
testcase_11 AC 3 ms
7,448 KB
testcase_12 AC 2 ms
7,492 KB
testcase_13 AC 2 ms
7,504 KB
testcase_14 AC 3 ms
7,672 KB
testcase_15 AC 2 ms
7,584 KB
testcase_16 AC 2 ms
7,592 KB
testcase_17 AC 4 ms
12,360 KB
testcase_18 AC 9 ms
19,992 KB
testcase_19 AC 15 ms
26,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define pb push_back
#define FOR(i,a,x) for(int i=(a);i<(x);i++)
#define rep(i,n)	FOR(i,0,n)
#define xFOR(i,a,x) for(int i=(a);i<=(x);i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end())
#define ub(vec,a) upper_bound(vec.begin(),vec.end())
#define uniq(vec) vec.erace(unique(vec.begin(),vec.end(),vec.end))
#define mp1(a,b,c) P1(a,P(b,c))
#define all(x) (x).begin(),(x).end()

#define debug(X) cout<<"["<<#X<<"]"<<X<<endl;



inline bool cheak(int x, int y, int xMax, int yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<typename T> inline string toString(const T &a) { ostringstream oss; oss << a; return oss.str(); }
template<class T> inline T sqr(T x) { return x*x; }


const int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };
const int mod = 1000000007;
const int INF = 1e9;
const int NIL = -1;

#define MAX_N 10010
#define MAX_K 100
#define MAX_V 10000

ll n;
ll dp[3][1000100];
ll ans;
int main() {
	cin >> n;
	dp[0][1] = 0;
	dp[1][1] = 1;
	dp[2][1] = 0;

	for (int k = 2; k <= n; k++) {
		dp[0][k] += (dp[2][k - 1] + dp[1][k - 1])%mod;
		dp[1][k] += dp[0][k - 1]%mod;
		dp[2][k] += dp[1][k - 1]%mod;
	}
	ans = (dp[0][n]%mod + dp[1][n]%mod + dp[2][n]%mod);
	cout << ans%mod << endl;
}
0