結果

問題 No.1681 +-*
ユーザー Hao He
提出日時 2025-04-12 14:06:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 1,015 bytes
コンパイル時間 1,729 ms
コンパイル使用メモリ 191,972 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-04-12 14:06:54
合計ジャッジ時間 4,726 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

// Problem: No.1681 +-*  第 1681 号+-*
// Contest: yukicoder
// URL: https://yukicoder.me/problems/no/1681
// Memory Limit: 512 MB
// Time Limit: 2000 ms
// Created by Herio

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 5;
const int inf = 0x3f3f3f3f, mod = 1e9 + 7;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define PII pair<int,int>
#define pb emplace_back
#define IOS ios::sync_with_stdio(false),cin.tie(nullptr)
#define mst(a,b) memset(a,b,sizeof a)
template <typename T>       //x=max(x,y)  x=min(x,y)
void cmx(T &x,T y){
    if(x<y) x=y;
}
template <typename T>
void cmn(T &x,T y){
    if(x>y) x=y;
}
#define sz(a) (int)a.size()
#define fi first
#define se second
ll a[N],p[N];
int main(){
	int n;cin>>n;
	rep(i,1,n) cin>>a[i];
	p[0]=1;
	for(int i=1;i<=n;i++) p[i]=p[i-1]*3%mod;
	ll x = 1;
	ll ans = 0;
	for(int i=1;i<=n;i++){
		x=x*a[i]%mod;
		ll w = (i==n)?1:2;
		ll t = (i==n)?1:p[n-1-i];
		ll s = x*w*t%mod;
		ans=(ans+s)%mod;
	}
	cout<<ans;
    return 0; 
}
0