結果
| 問題 |
No.1811 EQUIV Ten
|
| コンテスト | |
| ユーザー |
MasKoaTS
|
| 提出日時 | 2021-10-24 13:02:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 966 bytes |
| コンパイル時間 | 1,559 ms |
| コンパイル使用メモリ | 72,680 KB |
| 最終ジャッジ日時 | 2025-01-25 05:08:34 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
#include <iostream>
#include <vector>
#define rep(i, l, n) for (int i = (l); i < (n); i++)
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T> >;
const ll mod = 1000000007;
ll powmod(ll x, ll n) {
ll res = 1;
while (n > 0) {
if (n & 1) {
res = res * x % mod;
}
x = x * x % mod;
n >>= 1;
}
return res;
}
int main(void) {
int n; cin >> n;
if (n <= 3) {
cout << 0 << endl;
return 0;
}
V<ll> dp(8, 1);
rep(i, 3, n) {
V<ll> ndp(8);
ndp[0] = (dp[0] + dp[4]) % mod;
ndp[1] = (dp[0] + dp[4]) % mod;
ndp[2] = dp[1];
ndp[3] = (dp[1] + dp[5]) % mod;
ndp[4] = (dp[2] + dp[6]) % mod;
ndp[5] = (dp[2] + dp[6]) % mod;
ndp[6] = (dp[3] + dp[7]) % mod;
ndp[7] = (dp[3] + dp[7]) % mod;
rep(j, 0, 8) {
dp[j] = ndp[j];
}
}
ll sum = 0;
rep(i, 0, 8) {
sum = (sum + dp[i]) % mod;
}
ll ans = (powmod(2, n) + mod - sum) % mod;
cout << ans << endl;
return 0;
}
MasKoaTS