我是靠谱客的博主 温暖机器猫,这篇文章主要介绍HDU5086:Revenge of Segment Tree(规律题),现在分享给大家,希望可以做个参考。

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("%I64dn",a[1]);
            continue;
        }
        else
        {
            for(int i=1; i<=n; i++)
            {
                sum=(sum+a[i]*i%mod*(n-i+1)%mod)%mod;
            }
        }
        printf("%I64dn",sum);
    }
    return 0;
}

 

最后

以上就是温暖机器猫最近收集整理的关于HDU5086:Revenge of Segment Tree(规律题)的全部内容,更多相关HDU5086:Revenge内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(126)

评论列表共有 0 条评论

立即
投稿
返回
顶部