結果

問題 No.1681 +-*
ユーザー WunderMiku
提出日時 2025-04-15 22:10:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 468 bytes
コンパイル時間 4,877 ms
コンパイル使用メモリ 191,412 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-15 22:12:19
合計ジャッジ時間 7,229 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 6 RE * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+10, Mod = 1e9+7;
long long pre[N], _pow[N];

int main()
{
	int n;
	cin >> n;
	
	_pow[0] = 1, pre[0] = 1;
	for(int i = 1; i <= n; i ++)
	{
		int a;
		cin >> a;
		pre[i] = pre[i - 1] * a % Mod;
		_pow[i] = _pow[i - 1] * 3 % Mod;
	}
	
	long long res = 0;
	for(int k = 1; k < n; k++)
	{
		res = (res + (pre[k] * 2 * _pow[n - k - 1]) % Mod) % Mod;
	}
	
	res = (res + pre[n] % Mod) % Mod;
	
	cout << res;
 } 
0