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 ...
随机推荐
- ansible自动化运维工具的安装与使用
运行环境 centOS6.6 ansible ansible的功能还是比较多的,博主只用它在集群上进行批量部署软件和维护的功能,其他不多做研究,有需要的话这篇文章会慢慢补充. ansible特点 轻量 ...
- Mysql索引总结(二)
在数据库表中,对字段建立索引可以大大提高查询速度.假如我们创建了一个 mytable表: ) NOT NULL ); 在查找username="admin"的记录 SELECT * ...
- zw版【转发·台湾nvp系列Delphi例程】HALCON AffineTransImage
zw版[转发·台湾nvp系列Delphi例程]HALCON AffineTransImage unit Unit1;interfaceuses Windows, Messages, SysUtils, ...
- 【py网页】urlopen的补充,完美
urllib 是 python 自带的一个抓取网页信息一个接口,他最主要的方法是 urlopen(),是基于 python 的 open() 方法的.下面是主要说明: 1 urllib.urlopen ...
- Spring之AOP面向切片
一.理论基础: AOP(Aspectoriented programming)面向切片/服务的编程,在Spring中使用最多的是对事物的处理.而AOP这种思想在程序中很多地方可以使用的,比如说, ...
- 指针二次释放(_BLOCK_TYPE_IS_VALID)
[1]_BLOCK_TYPE_IS_VALID是什么错误? (1)最简单的示例代码如下: void main() { ); delete pA; delete pA; } (2)运行后崩溃截图如下: ...
- 我是如何对网站CSS进行架构的
by zhangxinxu from http://www.zhangxinxu.com 本文地址:http://www.zhangxinxu.com/wordpress/?p=944 一.写在前面的 ...
- 160919、使用AOP与注解记录Java日志
有些时候,我想要把每个运行过的方法接收到的参数.返回值和执行时间等信息记录(通过slf4j 和 log4j)下来.在AspectJ.jcabi-aspects和Java注解的帮助下我实现了这个想法. ...
- NDK
Android NDK是Google提供的开发Android原生程序的工具包,很多软件和病毒采用基于Android NDK动态库的调用技术,隐藏了在实现上的很多细节. 一.(windows版) 下载地 ...
- php curl应该怎么使用呢
原php默认并不进行此项功能的扩展,但还是有的,只是没有让它生效罢了.打开PHP安装目录,搜索以下三个文件 ssleay32.dll.libeay32.dll和 php_ curl .dll,一一拷贝 ...