http://acdream.info/problem?pid=1007

两个 long long 相乘会超long long

 #include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define maxn 10000
#define mod 10000000007
using namespace std; ll a[maxn];
ll n,k,t;
ll fMul(ll a, ll b) {
ll t = , y = a;
while(b) {
if(b & ) t = (t + y) % mod;
y = (y + y) % mod;
b >>= ;
}
return t;
} ll modExp(ll a, ll b) {
ll t = , y = a;
while(b) {
if(b & ) t = (fMul(t, y)) % mod;
y = (fMul(y, y)) % mod;
b >>= ;
}
return t;
} int main()
{
scanf("%lld",&t);
while(t--)
{
scanf("%lld%lld",&n,&k);
ll sum=;
for(int i=; i<n; i++)
{
scanf("%lld",&a[i]);
}
for(int i=; i<n; i++)
{
a[i]=((a[i]%mod)+mod)%mod;
ll c=modExp(a[i],k);
sum=(sum+c)%mod;
}
printf("%lld\n",sum);
}
return ;
}

Acdream a + b的更多相关文章

  1. ACdream 1214---矩阵连乘

    ACdream 1214---矩阵连乘 Problem Description You might have noticed that there is the new fashion among r ...

  2. acdream.LCM Challenge(数学推导)

     LCM Challenge Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Submit ...

  3. acdream.Triangles(数学推导)

    Triangles Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Submit Stat ...

  4. acdream.A Very Easy Triangle Counting Game(数学推导)

    A - A Very Easy Triangle Counting Game Time Limit:1000MS     Memory Limit:64000KB     64bit IO Forma ...

  5. acdream.Bet(数学推导)

    Bet Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Submit Status Pra ...

  6. acdream.郭式树(数学推导)

    郭式树 Time Limit:2000MS     Memory Limit:128000KB     64bit IO Format:%lld & %llu Submit Status Pr ...

  7. ACdream 1188 Read Phone Number (字符串大模拟)

    Read Phone Number Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Sub ...

  8. ACdream 1195 Sudoku Checker (数独)

    Sudoku Checker Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu Submit ...

  9. ACdream 1112 Alice and Bob(素筛+博弈SG函数)

    Alice and Bob Time Limit:3000MS     Memory Limit:128000KB     64bit IO Format:%lld & %llu Submit ...

  10. 数学 ACdream 1196 KIDx's Triangle

    题目传送门 /* 这道题花了好长时间AC,思路有,但是表达式少写了括号一直乱码,囧! 注意:a==0时要特判:) */ #include <cstdio> #include <alg ...

随机推荐

  1. mvc系统过滤器

    一.系统过滤器使用说明 1.OutputCache过滤器 OutputCache过滤器用于缓存你查询结果,这样可以提高用户体验,也可以减少查询次数.它有以下属性: Duration:缓存的时间,以秒为 ...

  2. APP开发者到期续费说明

    几步搞明白APP开发者续费,不再苦恼.1.APP开发者账号快满一年时,注册邮箱会收到一封提醒续费的邮件.主题类似5 days left to renew your iOS Developer Prog ...

  3. apache在windows上开启gzip的方法

    环境搭建好之后,默认并没有开启gzip功能.需要修改apache的httpd.conf配置文件进行开启.开启方法如下:1. httpd.conf中打开deflate_Module和headers_Mo ...

  4. msxml 操作xml

    1.简介 在.NET平台,微软为C#或托管C++程序员提供了丰富的类库,用以支持各种需求,其中就有对XML文件操作的丰富的类.例如XMLDocument, XmlElement等.但是C++标准库中并 ...

  5. DELL R720服务器安装Windows Server 2008 R2 操作系统图文详解

    DELL R720服务器安装Windows Server 2008 R2 操作系统图文详解 说明:此文章中部分图片为网络搜集,所以不一定为DELL R720服务器安装界面,但可保证界面内容接近DELL ...

  6. 使用Xmanager工具连接Linux服务器

    测试环境:RHEL5.8 1.# vi /usr/share/gdm/defaults.conf --修改以下三项Enable=true DisplaysPerHost=10 Port=177 All ...

  7. 【网络流#5】UVA 11082 最大流

    网络流题目最有意思的地方就是构图了,毕竟套模板每个人都会的 现在有一个矩阵,已知前i行元素之和a[i](1<=i<=n),前j列元素之和b[j](1<=j<=m),求一个可行的 ...

  8. 【网络流#3】hdu 1532 - Dinic模板题

    输入为m,n表示m条边,n个结点 记下来m行,每行三个数,x,y,c表示x到y的边流量最大为c 这道题的模板来自于网络 http://blog.csdn.net/sprintfwater/articl ...

  9. Myeclipse中点(.)不出来方法或者属性?

  10. C# 面向对象 , 类与对象

    一,类的字段 类的字段, 就是类里面的 数据. 二,类的方法 1 , 函数的重载 , 如何判断:  是由两个或多个同名函数组成的,但是函数要有不同的参数.或个数.(参数  是函数的输入的东西) shu ...