1001 Revenge of Segment Tree
这个题目好像很简单的样子,但是我错了好多次
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <limits.h>
#include <string.h>
#include <algorithm>
#include <functional>
using namespace std;
#define maxn 447000+5
#define mm 1000000007
typedef long long ll;
ll a[maxn];
ll kk[maxn];
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int t;scanf("%d",&t);
while(t--){
ll n;scanf("%I64d",&n);
for (int i=1;i<=n;i++){
scanf("%I64d",&a[i]);
}
kk[1]=n;kk[n]=n;
for (ll i=2;i<=n/2;i++){
kk[i]=(kk[i-1]+n-2*(i-1))%mm;
kk[n+1-i]=kk[i];
}
if (n%2==1){
kk[n/2+1]=(kk[n/2]+1)%mm;
}
ll ans=0;
for (ll i=1;i<=n;i++){
ans=((ans+((kk[i])%mm*(a[i])%mm))%mm)%mm;
}
printf("%I64d\n",ans);
}
return 0;
}