首页 > 其他 > 详细

HDU5086:Revenge of Segment Tree(规律题)

时间:2014-11-02 20:46:38      阅读:248      评论:0      收藏:0      [点我收藏+]

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;
}

 

HDU5086:Revenge of Segment Tree(规律题)

原文:http://www.cnblogs.com/zhangmingcheng/p/4069805.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!