#include <iostream>
#include <cstdio>
using namespace std;
const int M = 1e9 + 7;
#define ll long long
int main()
{
int n;
ll x, ans = 0;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
{
scanf("%lld", &x);
ans += ans * x % M + x;
ans %= M;
}
printf("%lld", ans);
return 0;
}
看题目当成一道规划题了,没多想。
解题核心ans += ans * x % M + x
即每个数乘N次加它自身。
原文:https://www.cnblogs.com/thx2199/p/14589059.html