結果
| 問題 |
No.1681 +-*
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-17 23:09:48 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,150 bytes |
| コンパイル時間 | 744 ms |
| コンパイル使用メモリ | 79,232 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-29 21:57:34 |
| 合計ジャッジ時間 | 2,748 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 4 WA * 14 |
ソースコード
#include <iostream>
#include <limits>
#include <array>
#define FOR(i, s, n) for(auto i = (s); i < n; ++i)
#define REP(i, n) FOR(i, decltype(n)(), n)
using ll = long long;
constexpr ll mod = 1000000007;
template <class T, T b>
class pow_preproc {
using array_t = std::array<T, std::numeric_limits<T>::digits>;
static constexpr array_t get_dp() {
array_t dp = {b % mod};
FOR(i, 1, std::numeric_limits<T>::digits) {
dp[i] = (dp[i - 1] * dp[i - 1]) % mod;
}
return dp;
}
static constexpr array_t _dp = get_dp();
public:
static constexpr T get_pow(T x) {
if(x < 0) return 0;
T y = 1;
for(int i = 0; x; ++i) {
if(x % 2) {
y *= _dp[i];
y %= mod;
}
x /= 2;
}
return y;
}
};
std::array<int, 200001> a = {};
using pow3 = pow_preproc<ll, 3>;
int main() {
int n;
ll sum = 0;
ll muls = 1;
std::cin >> n;
REP(i, n) {
ll a;
std::cin >> a;
muls *= a; muls %= mod;
ll p = pow3::get_pow(n - i - 2);
if(p <= 0) p = 1;
else {
p *= 2;
p %= mod;
}
sum += muls * p; if(sum > mod) sum -= mod;
}
std::cout << sum << '\n';
}