http://acm.hdu.edu.cn/showproblem.php?pid=5086

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <queue>
#include <map>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#define mod 1000000007
using namespace std;
int n;
__int64 a[447010];
__int64 sum;
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        sum=0;
        scanf("%d",&n);
        a[0]=0;
        for(int i=1; i<=n; i++)
        {
            scanf("%I64d",&a[i]);
        }
        if(n==1)
        {
            printf("%I64d\n",a[1]);
            continue;
        }
        else
        {
            for(int i=1; i<=n; i++)
            {
                sum=(sum+a[i]*i%mod*(n-i+1)%mod)%mod;
            }
        }
        printf("%I64d\n",sum);
    }
    return 0;
}

 

相关文章:

  • 2021-07-04
  • 2022-12-23
  • 2021-08-21
  • 2021-12-06
  • 2022-12-23
  • 2021-10-17
  • 2021-10-09
  • 2021-07-09
猜你喜欢
  • 2021-10-16
  • 2021-08-23
  • 2022-03-07
  • 2021-11-24
  • 2022-12-23
  • 2021-12-02
  • 2022-02-12
相关资源
相似解决方案