結果

問題 No.314 ケンケンパ
ユーザー penguinshunya
提出日時 2019-03-25 13:02:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 28 ms / 1,000 ms
コード長 2,641 bytes
コンパイル時間 776 ms
コンパイル使用メモリ 106,292 KB
最終ジャッジ日時 2025-01-07 00:28:16
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))
using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;
template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }
template<int mod> class modint {
public:
int x;
modint(): x(0) {}
modint(int a) { x = a % mod; if (x < 0) x += mod; }
modint &operator+=(modint that) { x = (x + that.x) % mod; return *this; }
modint &operator-=(modint that) { x = (x + mod - that.x) % mod; return *this; }
modint &operator*=(modint that) { x = (long long) x * that.x % mod; return *this; }
modint &operator/=(modint that) { return *this *= that.inverse(); }
modint operator-() { return modint(-this->x); }
friend ostream& operator<<(ostream &out, modint m) { return out << m.x; }
modint inverse() {
int a = x, b = mod, u = 1, v = 0;
while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
return modint(u);
}
#define op(o, p) modint operator o(modint that) { return modint(*this) p that; }
op(+, +=) op(-, -=) op(*, *=) op(/, /=)
#undef op
#define op(o) bool operator o(modint that) const { return x o that.x; }
op(==) op(!=) op(<) op(<=) op(>) op(>=)
#undef op
};
using mint = modint<1000000007>;
mint dp[1000010][3][2];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(16);
int n; cin >> n;
dp[1][1][0] = 1;
reps(i, n - 1) rep(j, 3) rep(k, 2) {
if (j >= 1) dp[i + 1][0][1] += dp[i][j][k];
if (j == 1) dp[i + 1][2][0] += dp[i][j][k];
if (k == 1) dp[i + 1][1][0] += dp[i][j][k];
}
mint ans = 0;
rep(j, 3) rep(k, 2) {
ans += dp[n][j][k];
}
cout << ans << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0