結果

問題 No.1681 +-*
ユーザー 同传man辛苦了同传man辛苦了
提出日時 2021-10-18 19:51:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 510 bytes
コンパイル時間 1,608 ms
コンパイル使用メモリ 167,200 KB
実行使用メモリ 6,732 KB
最終ジャッジ日時 2023-10-19 19:54:01
合計ジャッジ時間 4,177 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,660 KB
testcase_01 AC 2 ms
5,660 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 51 ms
6,328 KB
testcase_14 AC 100 ms
6,732 KB
testcase_15 AC 3 ms
5,660 KB
testcase_16 AC 2 ms
5,660 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
const int MAXN = 2e5 + 10;
int n,a[200005],ans,sum[200005];
int qpow(int x,int y){
	int res=1;
	while(y){
		if(y&1){
			(res*=x)%mod;
		}
		(x*=x)%=mod;
		y>>=1;
	}
	return res;
}
void solve(){
	sum[0]=1;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum[i]=sum[i-1]*a[i]%mod;
	}
	for(int i=1;i<n;i++){
		(ans+=sum[i]*qpow(3,n-i-1)%mod*2%mod)%=mod;
	}
	(ans+=sum[n])%=mod;
	cout<<ans%mod;
}
signed main(){
	solve();
}
0