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. adb getprop setprop watchprop用法

    在android系统中,有一些初始化的配置文件,例如: /init.rc /default.prop /system/build.prop 文件里面里面配置了开机设置的系统属性值,这些属性值,可以通过 ...

  2. GMU

    NEXT | 不错过任何一个新产品 百度开源 Mobile UI 组件库,提供 Web app.Pad 端简单易用的 UI 组件 发表评论

  3. 16个不错的git别名

    git 是一个非常棒的源代码管理工具,它的使用已经完全整合到开发的工作流当中:同时,git 还是一个 review/OTAP/deployment 工具. 当在 CLI 中使用 git 时,有时必须输 ...

  4. 小白鼓捣GIT的心得

    这篇文章写给那些之前没接触过git的开发人员,算是一个参考吧,希望能有所帮助,我也会尽量写的详细. 今天刚开通了博客,趁着兴致,想着把积累已久的git问题也一并搞懂吧,于是乎吃完饭开始鼓捣,从下载GI ...

  5. 你需要知道的九大排序算法【Python实现】之插入排序

    三.插入排序 基本思想:插入排序的基本操作就是将一个数据插入到已经排好序的有序数据中,从而得到一个新的.个数加一的有序数据,算法适用于少量数据的排序,时间复杂度为O(n^2).是稳定的排序方法.插入算 ...

  6. JAVA冒泡排序/JAVA冒泡排序再找出给定数据中的最大值最小值/JAVA数组排序

    //数组中排序    int in[] = {1,6,5,8,9};    Arrays.sort(in);    for(int i=0;i<in.length;i++){       Sys ...

  7. Java基础知识强化21:Java中length、length()、size()区别

    1.java中的length属性是针对数组说的,比如说你声明了一个数组,想知道这个数组的长度则用到了length这个属性.2.java中的length()方法是针对字符串String说的,如果想看这个 ...

  8. ssh注解开发

    引入需要的jar包 @Entity public class Teacher { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) priva ...

  9. hdu 2218

    题意: 切蛋糕问题 水题...... AC代码: #include <iostream> using namespace std; int main() { int a[6],i,n; c ...

  10. MyEclipse Web Project导入Eclipse Dynamic Web Project,无法部署到tomcat问 题

    做作业遇到一个小问题,将MyEclipse Web Project导入到Eclipse中开发.在部署到tomcat时,发现无法发布这个项目. 问题分析: MyEclipse Web Project被识 ...