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 ...
随机推荐
- windows系统调用 线程 启动与挂起
#include "iostream" #include "windows.h" using namespace std; class CWorkerThrea ...
- java通过LinkedList实现堆栈和队列数据结构
package shb.java.demo3; import java.util.LinkedList; public class TestLinkedList { /** * @author sha ...
- paper 63 :函数比较:imfilter与fspecial
功能:对任意类型数组或多维图像进行滤波. 用法:B = imfilter(A,H) B = imfilter(A,H,option1,option2,...) 或写作g = imfilter(f, w ...
- paper 44 :颜色矩和颜色相关图(color correlogram)
- mongodb的js操作
在包含url的test库中运行test.js mongo url:port/test test.js
- Java IO总结之缓冲读入文件
package com.io; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException ...
- 夺命雷公狗ThinkPHP项目之----企业网站18之网站配置列表页的完成
我们点击下配置列表即可查看我们列表页的配置信息了: 其实这个最简单了,首先我们先来完成他控制器的代码: public function lists(){ $mod = M('Conf')->se ...
- 为archlinux配置cron
cron的作用:cron可以用来周期性地自动执行一些命令. cron的实现:cron有很多实现版本,例如:cronie, dcron, fcron, bcron, vixie-cron,我安装的是 c ...
- 在TVideoGrabber中如何在预览时设置相机属性
在使用TVideoGrabber进行预览时,如何设置相机的属性呢?比如曝光.对比度.亮度等. 下面来看一下,如何通过编程来调整这些设置: ——通过指定VideoDevice属性(在VideoDevic ...
- window7快捷键
新建文件夹:Shift +F10 松手 shift + w 两遍 Enter shift+F Enter