結果

問題 No.1681 +-*
ユーザー laneguelanegue
提出日時 2021-09-17 22:17:57
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 640 ms / 2,000 ms
コード長 357 bytes
コンパイル時間 1,779 ms
コンパイル使用メモリ 224,096 KB
実行使用メモリ 14,176 KB
最終ジャッジ日時 2023-09-04 14:08:10
合計ジャッジ時間 11,041 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 5 ms
4,380 KB
testcase_03 AC 5 ms
4,376 KB
testcase_04 AC 5 ms
4,380 KB
testcase_05 AC 629 ms
9,100 KB
testcase_06 AC 629 ms
9,076 KB
testcase_07 AC 626 ms
10,072 KB
testcase_08 AC 635 ms
13,428 KB
testcase_09 AC 635 ms
12,828 KB
testcase_10 AC 640 ms
12,808 KB
testcase_11 AC 636 ms
13,652 KB
testcase_12 AC 632 ms
14,176 KB
testcase_13 AC 318 ms
7,040 KB
testcase_14 AC 632 ms
13,156 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 634 ms
12,952 KB
testcase_18 AC 635 ms
13,052 KB
testcase_19 AC 625 ms
12,988 KB
権限があれば一括ダウンロードができます

ソースコード

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