東京海上日動 プログラミングコンテスト2021 (AtCoder Regular Contest 122)
翻译中…
Problem Statement
翻译中…
You are given a sequence of $N$ non-negative integers: $A_1,A_2,\cdots,A_N$.
翻译中…
Consider inserting a + or - between each pair of adjacent terms to make one formula.
翻译中…
There are $2^{N-1}$ such ways to make a formula. Such a formula is called good when the following condition is satisfied:
翻译中…
-does not occur twice or more in a row.
翻译中…
Find the sum of the evaluations of all good formulae. We can prove that this sum is always a non-negative integer, so print it modulo $(10^9+7)$.
翻译中…
Constraints
翻译中…
$1 \leq N \leq 10^5$$1 \leq A_i \leq 10^9$- All values in input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
A_1 A_2 \cdots A_N
翻译中…
Output
翻译中…
Print the sum modulo $(10^9+7)$.
翻译中…
样例
Input #1
3
3 1 5
Output #1
15
We have the following three good formulae:
- $3+1+5=9$
- $3+1-5=-1$
- $3-1+5=7$
Note that $3-1-5$ is not good since`-` occurs twice in a row in it. Thus, the answer is $9+(-1)+7=15$.
Input #2
4
1 1 1 1
Output #2
10
We have the following five good formulae:
- $1+1+1+1=4$
- $1+1+1-1=2$
- $1+1-1+1=2$
- $1-1+1+1=2$
- $1-1+1-1=0$
Thus, the answer is $4+2+2+2+0=10$.
Input #3
10
866111664 178537096 844917655 218662351 383133839 231371336 353498483 865935868 472381277 579910117
Output #3
279919144
Print the sum modulo $(10^9+7)$.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。