Acdream a + b
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的更多相关文章
- ACdream 1214---矩阵连乘
ACdream 1214---矩阵连乘 Problem Description You might have noticed that there is the new fashion among r ...
- acdream.LCM Challenge(数学推导)
LCM Challenge Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit ...
- acdream.Triangles(数学推导)
Triangles Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit Stat ...
- acdream.A Very Easy Triangle Counting Game(数学推导)
A - A Very Easy Triangle Counting Game Time Limit:1000MS Memory Limit:64000KB 64bit IO Forma ...
- acdream.Bet(数学推导)
Bet Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit Status Pra ...
- acdream.郭式树(数学推导)
郭式树 Time Limit:2000MS Memory Limit:128000KB 64bit IO Format:%lld & %llu Submit Status Pr ...
- ACdream 1188 Read Phone Number (字符串大模拟)
Read Phone Number Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Sub ...
- ACdream 1195 Sudoku Checker (数独)
Sudoku Checker Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit ...
- ACdream 1112 Alice and Bob(素筛+博弈SG函数)
Alice and Bob Time Limit:3000MS Memory Limit:128000KB 64bit IO Format:%lld & %llu Submit ...
- 数学 ACdream 1196 KIDx's Triangle
题目传送门 /* 这道题花了好长时间AC,思路有,但是表达式少写了括号一直乱码,囧! 注意:a==0时要特判:) */ #include <cstdio> #include <alg ...
随机推荐
- Java中Websocket使用实例解读
介绍 现在很多网站为了实现即时通讯,所用的技术都是轮询(polling).轮询是在特定的的时间间隔(如每1秒),由浏览器对服务器发出HTTP request,然后由服务器返回最新的数据给客服端的浏览器 ...
- SKPhysicsJointFixed类
继承自 NSObject 符合 NSCoding(SKPhysicsJoint)NSObject(NSObject) 框架 /System/Library/Frameworks/SpriteKit. ...
- List 去处自定义重复对象方法
list泛型集合去除重复项,对于单一的某个字段非常简单,但是对于一些自定义要求的还需自定义规则.例子代码: /************绑定乘客信息********/ List<RT.Model. ...
- jquery.ajax提交多值(数组)
偶尔会遇到类似复选框的一个属性存在多值情况,若使用ajax提交的化,设置data :{ids:[1,2,3,4]} 提交后,后台无法使用ids获取到数据. 这里可以用到ajax的 traditiona ...
- js添加onclick函数
document.getElementById('Add').setAttribute("onclick",AddNum()); 相当于不停的调用Addnum函数 应改成docum ...
- Nginx环境下常见的开源项目重写汇总
我们做PHP开发的,作者寒冰我觉得大部分时候都在跟开源的系统打交道.比如:Discuz.PHPCMS.ecshop.wordpress等开源系统.一般我们都是在本地搭建测试环境,用的web服务器都是a ...
- Memcached 搭建过程
原文链接:http://www.open-open.com/lib/view/open1324368235733.html 安装 memcached 服务端 yum -y install libeve ...
- Microsoft Office 2007 Professional Plus+ 正版密钥
Microsoft Office 2007 Professional Plus+ 正版密钥 说微软原版,自有Microsoft官方MSDN网站有关下载的校验值为证(附后).密钥安装后 ...
- Springmvc整合mybatis
http://blog.csdn.net/geloin/article/details/7536968 http://blog.csdn.net/woshi74/article/details/378 ...
- MySQL教程:数据库具体操作
1. 连接数据库服务器 $ ./mysql -h host_name -u user_name -p -h host_name(--host=host_name),连接的数据库主机名,如果在本地主机上 ...