ACdream 1007 (快速幂)
a + b
Time Limit: 2000/1000MS (Java/Others)Memory Limit: 128000/64000KB (Java/Others)Problem Description
Input
Output
Sample Input
2
3 1
1 2 3
3 10
1 2 3Sample Output
6
60074
/*************************************************************************
> File Name: 1007.cpp
> Author: Stomach_ache
> Mail: sudaweitong@gmail.com
> Created Time: 2014年08月11日 星期一 07时44分39秒
> Propose:
************************************************************************/
#include <cstdio>
/*Let's fight!!!*/ typedef long long LL;
const LL mod = (LL)1e10 + ; LL mul(LL a, LL b) {
LL res = ;
while (b) {
if (b&) if ((res += a) >= mod) res -= mod;
a <<= ;
if (a >= mod) a -= mod;
b >>= ;
}
return res;
} LL mod_pow(LL a, LL b) {
LL res = ;
while (b) {
if (b&) res = mul(res, a);
a = mul(a, a);
b >>= ;
}
return res;
} int main(void) {
int t;
scanf("%d", &t);
while (t--) {
LL n, k, ans = , x;
scanf("%lld %lld", &n, &k);
k %= 9560995488LL; for (int i = ; i < n; i++) {
scanf("%lld", &x);
ans += mod_pow((x%mod+mod)%mod, k);
if (ans >= mod) ans -= mod;
} printf("%lld\n", ans);
} return ;
}
ACdream 1007 (快速幂)的更多相关文章
- 【矩阵快速幂】bzoj1297 [SCOI2009]迷路
1297: [SCOI2009]迷路 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1407 Solved: 1007[Submit][Status ...
- 【洛谷】P1313 计算系数(快速幂+杨辉三角)
题目 题目描述 给定一个多项式(by+ax)^k,请求出多项式展开后x^n*y^m 项的系数. 输入输出格式 输入格式: 输入文件名为factor.in. 共一行,包含5 个整数,分别为 a ,b , ...
- 矩阵快速幂 HDU 4565 So Easy!(简单?才怪!)
题目链接 题意: 思路: 直接拿别人的图,自己写太麻烦了~ 然后就可以用矩阵快速幂套模板求递推式啦~ 另外: 这题想不到或者不会矩阵快速幂,根本没法做,还是2013年长沙邀请赛水题,也是2008年Go ...
- 51nod 算法马拉松18 B 非010串 矩阵快速幂
非010串 基准时间限制:1 秒 空间限制:131072 KB 分值: 80 如果一个01字符串满足不存在010这样的子串,那么称它为非010串. 求长度为n的非010串的个数.(对1e9+7取模) ...
- hdu 4704 Sum (整数和分解+快速幂+费马小定理降幂)
题意: 给n(1<n<),求(s1+s2+s3+...+sn)mod(1e9+7).其中si表示n由i个数相加而成的种数,如n=4,则s1=1,s2=3. ...
- Codeforces632E Thief in a Shop(NTT + 快速幂)
题目 Source http://codeforces.com/contest/632/problem/E Description A thief made his way to a shop. As ...
- GDUFE-OJ 1203x的y次方的最后三位数 快速幂
嘿嘿今天学了快速幂也~~ Problem Description: 求x的y次方的最后三位数 . Input: 一个两位数x和一个两位数y. Output: 输出x的y次方的后三位数. Sample ...
- 51nod 1113 矩阵快速幂
题目链接:51nod 1113 矩阵快速幂 模板题,学习下. #include<cstdio> #include<cmath> #include<cstring> ...
- 【66测试20161115】【树】【DP_LIS】【SPFA】【同余最短路】【递推】【矩阵快速幂】
还有3天,今天考试又崩了.状态还没有调整过来... 第一题:小L的二叉树 勤奋又善于思考的小L接触了信息学竞赛,开始的学习十分顺利.但是,小L对数据结构的掌握实在十分渣渣.所以,小L当时卡在了二叉树. ...
- HDU5950(矩阵快速幂)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5950 题意:f(n) = f(n-1) + 2*f(n-2) + n^4,f(1) = a , f(2 ...
随机推荐
- Python学习day35-并发编程(1)
figure:last-child { margin-bottom: 0.5rem; } #write ol, #write ul { position: relative; } img { max- ...
- CAS增加免登陆(Remember Me)功能
1. 打开deployerConfigContext.xml 在 authenticationManager 的bean中增加 <property name="authenticati ...
- 第一个简单netty程序
一个简单的netty的程序,主要是netty的客户端和服务端通信. 大部分说明都写在代码注释中 netty server TimeServer import io.netty.bootstrap.Se ...
- 从github下载项目出现yes/no的选项,无法下载项目
解决办法: # 本地执行: ssh-keygen # 将id_rsa_pub文件中公钥拷贝到github上的ssh认证 oodful@:~/Volumes/Term2 :::$cat ~/.ssh/i ...
- 长按触发(PC端和移动端)
$.fn.longPress = function(fn) { var timeout = undefined; var $this = this; for(var i = 0;i<$this. ...
- HZOI20190818模拟25题解
题面:https://www.cnblogs.com/Juve/articles/11372379.html A:字符串 其实是CATALAN数水题... 和网格一毛一样:https://www.cn ...
- spfa模版
#include<bits/stdc++.h> using namespace std; int n,m;//点边 int beginn; ],v[],w[]; ],nextt[]; ]; ...
- LL(1),LR(0),SLR(1),LALR(1),LR(1)对比与分析
前言:考虑到这几种文法如果把具体内容讲下来肯定篇幅太长,而且繁多的符号对初学者肯定是极不友好的,而且我相信看这篇博客的人已经对这几个文法已经有所了解了,本篇博客的内容只是对 这几个文法做一下对比,加深 ...
- 让pandoc输出pdf时支持中文
主机环境为:Ubuntu 12.04 LTS.对于RH系列,yum安装包的名称可能会有不同,不过yum联想能力比较强,应该不是问题. 安装pandoc,安装tex-live sudo apt-get ...
- 13 个最佳 JavaScript 数据网格库
13 个最佳 JavaScript 数据网格库 转自:开源中国 www.oschina.net/translate/best-javascript-data-grid-libraries Java ...