HDU 2817 A sequence of numbers 整数快速幂
A sequence of numbers
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4550 Accepted Submission(s): 1444
You can assume 0 < K <= 10^9, and the other three numbers are in the range [0, 2^63). All the numbers of the sequences are integers. And the sequences are non-decreasing.
16
#include<iostream>
#define mod 200907
using namespace std;
__int64 mi(__int64 q,__int64 k)
{
__int64 sum=;
while(k)
{
) sum=(sum*q)%mod;
q=(q*q)%mod;
k>>=;
}//整数快速幂
return sum;
}
int main()
{
int t;
__int64 a, b, c, k;
cin>>t;while(t--)
{
cin>>a>>b>>c>>k;
if(c-b==b-a)
cout<<(a%mod+(k-)%mod*((c-b)%mod))%mod<<endl;
else
cout<<(mi(c/b,--k)%mod*a%mod)%mod<<endl;
}
;
}
HDU 2817 A sequence of numbers 整数快速幂的更多相关文章
- hdu 2817 A sequence of numbers(快速幂取余)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2817 题目大意:给出三个数,来判断是等差还是等比数列,再输入一个n,来计算第n个数的值. #inclu ...
- 杭电 2817 A sequence of numbers【快速幂取模】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2817 解题思路:arithmetic or geometric sequences 是等差数列和等比数 ...
- hdoj 2817 A sequence of numbers【快速幂】
A sequence of numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Ot ...
- HDU 2817 A sequence of numbers
http://acm.hdu.edu.cn/showproblem.php?pid=2817 __int64 pow_mod (__int64 a, __int64 n, __int64 m)快速幂取 ...
- hdu 2817 A sequence of numbers(快速幂)
Problem Description Xinlv wrote some sequences on the paper a long time ago, they might be arithmeti ...
- hdu 3117 Fibonacci Numbers 矩阵快速幂+公式
斐波那契数列后四位可以用快速幂取模(模10000)算出.前四位要用公式推 HDU 3117 Fibonacci Numbers(矩阵快速幂+公式) f(n)=(((1+√5)/2)^n+((1-√5) ...
- 2017ACM暑期多校联合训练 - Team 8 1011 HDU 6143 Killer Names (容斥+排列组合,dp+整数快速幂)
题目链接 Problem Description Galen Marek, codenamed Starkiller, was a male Human apprentice of the Sith ...
- 题解报告:hdu 1576 A/B(exgcd、乘法逆元+整数快速幂)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1576 Problem Description 要求(A/B)%9973,但由于A很大,我们只给出n(n ...
- POJ 1995 Raising Modulo Numbers 【快速幂取模】
题目链接:http://poj.org/problem?id=1995 解题思路:用整数快速幂算法算出每一个 Ai^Bi,然后依次相加取模即可. #include<stdio.h> lon ...
随机推荐
- paper 61:计算机视觉领域的一些牛人博客,超有实力的研究机构等的网站链接
转载出处:blog.csdn.net/carson2005 以下链接是本人整理的关于计算机视觉(ComputerVision, CV)相关领域的网站链接,其中有CV牛人的主页,CV研究小组的主页,CV ...
- Oracle Savepoint
1.目的: Use the SAVEPOINT statement to identify a point in a transaction to which you can later roll b ...
- 常用的网络配置命令 ifconfig 所在的包
通过rpm的数据库反查 ifconfig这个可执行文件的提供者,得出这个文件属于一个叫 net-tools 的包
- 关于nandflash与norflash
读取速度:nor > nand 写入速度:nand > nor 擦除速度:nand 4ms,nor 5s nand的擦除单元更小,相应的擦除电路更少. nand的实际应用方式比nor复杂, ...
- 【sinatra】设置默认的端口
加入 set :port, 8888 #默认4567
- PHP memcached 扩展的安装
PHP memcached 扩展的安装 1.下载相关的源码包(软件版本自己选择) memcached-1.4.15 , http://memcached.org/ //Memcached服务端. me ...
- Mac下使用Automator实现截屏编辑保存
以前在Windows下使用百度或者搜狗输入法的截图工具很方便.❶快捷键(Alt+X,我设置的是这个),❷选择区域,❸编辑所选区域,包括添加文字,线条框框,调色,❹点击『✔️』选择保存位置,修改文件名保 ...
- Class.forName("ClassName")与ClassName.class的区别
引发问题的来源:最近在看比较深入的JVM相关的书,不得不感慨,JVM确实是比较深奥,很多地方难以理解不说,在网上还找不到什么资料,发现一个左思右想都想不明白的问题上网来搜索,结果基本上都是从书上cop ...
- 解决HP服务器安装Centos7 x64无法识别硬盘
公司有一台老旧的HP服务器——HP BL460c G7 SmartArray P410i.由于种种原因,需要重新安装操作系统Centos7.但是经过各种努力,Centos7的安装程序就是无法识别服务器 ...
- vsftpd
vi /etc/vsftpd.conf and add the following allow_writeable_chroot=YES sudo service vsftpd restart