問題一覧 > 通常問題

No.1681 +-*

レベル : / AI推定難易度 : 1300 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 204
作問者 : Sumitacchan / テスター : 👑 hitonanode ygussany
お気に入りにしたユーザー ProblemId : 6806 / 自分の提出
問題文最終更新日: 2021-09-30 21:27:50
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 314 (順位表) の他の問題:

Problem Statement

There is a sequence of $N$ non-negative integers $A_1,A_2,\dots ,A_N$.

Consider forming an expression by inserting one of the $3$ kinds of operators $+,-,\times$ between each pair of adjacent $2$ terms of this sequence, and then evaluating it.
As per the usual rules, multiplication takes precedence over the other operations.

There are $3^{N-1}$ possible expressions. Find the sum of the evaluation results of all of these expressions.
Since the answer can be very large, output it modulo $10^9+7$ (it can be proved that the answer is always a non-negative integer).

Input

$N$
$A_1\ \ A_2\ \ \cdots\ \ A_N$

  • $2\le N\le 2\times 10^5$
  • $0\le A_i \le 10^9$
  • All inputs are integers.

Output

Output the sum of the evaluation results of the possible expressions, modulo $10^9+7$.

Sample

Sample 1
Input
3
1 2 3
Output
16

The sum of the evaluation results of the $9$ expressions, such as $1+2-3=0,\ 1+2\times 3=7$, is $16$.

Sample 2
Input
5
1001 1002 1003 1004 1005
Output
342428517

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。