标签:
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1541 Accepted Submission(s): 552
#include <iostream> #include <stdio.h> #include <math.h> #include <stdlib.h> #include <algorithm> #include <string.h> using namespace std; typedef long long LL; const int mod = 1000000007; const int N = 447005; int n; LL a[N]; LL dp[N]; int main() { int tcase; scanf("%d",&tcase); while(tcase--){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%lld",&a[i]); } dp[1] = a[1]; for(int i=2;i<=n;i++){ dp[i] = (dp[i-1] + (i*a[i])%mod)%mod; } LL ans = 0; for(int i=1;i<=n;i++){ ans = (ans+dp[i])%mod; } printf("%lld\n",ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/liyinggang/p/5657928.html