結果

問題 No.1681 +-*
ユーザー lanegue
提出日時 2021-09-17 22:17:57
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 679 ms / 2,000 ms
コード長 357 bytes
コンパイル時間 2,051 ms
コンパイル使用メモリ 232,776 KB
実行使用メモリ 13,692 KB
最終ジャッジ日時 2024-06-22 12:31:19
合計ジャッジ時間 10,987 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;
void main(){
	auto n = readln.chomp.to!ulong;
	auto a = readln.chomp.split(" ").to!(ulong[]);
	ulong M = 10 ^^ 9 + 7;
	ulong x = 1;
	ulong c = 2 * powmod(3U, n - 1, M);
	ulong r = 0;
	for(auto i = 0; i < n - 1; i++){
		x *= a[i];
		x %= M;
		c *= powmod(3U, M - 2, M);
		c %= M;
		r += x * c;
		r %= M;
	}
	r += x * a[n - 1];
	writeln(r % M);
}
0