HDU 2817 A sequence of numbers
http://acm.hdu.edu.cn/showproblem.php?pid=2817
__int64 pow_mod (__int64 a, __int64 n, __int64 m)快速幂取模函数。
A sequence of numbers
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4047 Accepted Submission(s):
1243
ago, they might be arithmetic or geometric sequences. The numbers are not very
clear now, and only the first three numbers of each sequence are recognizable.
Xinlv wants to know some numbers in these sequences, and he needs your
help.
there are N sequences. Each of the following N lines contain four integers. The
first three indicating the first three numbers of the sequence, and the last one
is K, indicating that we want to know the K-th numbers of the
sequence.
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.
number module (%) 200907.
#include<stdio.h>
#include<string.h>
#define MOD 200907
__int64 pow_mod (__int64 a, __int64 n, __int64 m)
{
if(n==)
return %m;
if(n==)
return a%m;
__int64 x=pow_mod(a,n/,m);
__int64 ans=x*x%m;
if(n%==) ans=ans*a%m; return ans;
} int main()
{
double a,b,c;
int t;
int k;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf%lf%d",&a,&b,&c,&k);
if(a+c==*b)
{
__int64 a1=(__int64 )a;
__int64 d=(__int64 )(b-a);
int ans=(a1%MOD+((k-)%MOD)*(d%MOD))%MOD;
printf("%d\n",ans);
}
else
{
__int64 a1=(__int64)a;
__int64 t1=(__int64)(a1%MOD);
double q1=(b/a);
__int64 q2=(__int64)q1;
__int64 q=(__int64)q2;
__int64 tmp=pow_mod(q,k-,MOD);
int ans=(t1*tmp)%MOD;
printf("%d\n",ans);
}
}
return ;
}
HDU 2817 A sequence of numbers的更多相关文章
- HDU 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(快速幂)
Problem Description Xinlv wrote some sequences on the paper a long time ago, they might be arithmeti ...
- hdu 2817 A sequence of numbers(快速幂取余)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2817 题目大意:给出三个数,来判断是等差还是等比数列,再输入一个n,来计算第n个数的值. #inclu ...
- 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 2187 A sequence of numbers
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2817 题意: 给定三个数,判断是等差数列还是等比数列,然后输出第k项. 做法:直接判断即可 #inc ...
- 杭电 2817 A sequence of numbers【快速幂取模】
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2817 解题思路:arithmetic or geometric sequences 是等差数列和等比数 ...
- HDU 1711 Number Sequence(数列)
HDU 1711 Number Sequence(数列) Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...
- HDU 1711 Number Sequence (字符串匹配,KMP算法)
HDU 1711 Number Sequence (字符串匹配,KMP算法) Description Given two sequences of numbers : a1, a2, ...... , ...
- HDU 5860 Death Sequence(死亡序列)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
随机推荐
- 解决 IE 不支持 document.getElementsByClassName() 的方法
//create method getElementsByClassName for document if(!document.getElementsByClassName){ document.g ...
- 【转】循环递归遍历XML文档或按某要求遍历XML文档
<?xml version="1.0" encoding="UTF-8"?> <catalog> <cd> <titl ...
- 使用Github总结
1. 使用Git GUI 首先熟悉一下GUI,如下: 第一步,首先将代码fork到自己的版本库下面,如下: 并获取clone URL,如下图: 然后点击GUI克隆已有版本库,如下图: 点击克隆就可以得 ...
- Delphi调用一个外部程序时,如何把外部程序的窗体放在主程序窗体的Panel上?
uses shellapi; ... procedure TForm1.Button2Click(Sender: TObject); var vh: HWND; begin ShellExecute( ...
- web2py--------------用web2py写 django的例子 --------建立一个投票应用(3)
我们建立了数据模型,然后这次来进行页面的展示 1.这里是列表页面的 control 这里是dal的语法 只有两行 第一行 是查询出所有问题,也就是问题的id大于0 第二行是返回问题的列表 这里是vie ...
- HTTP - PUT 上传文件/Shell (二)
上一篇文章 HTTP - PUT 上传文件/Shell 讲到自己搭了一个环境,去测试HTTP - PUT上传Shell.最近又遇到几个PUT上传的例子,也成功上传了几次,来分享一下思密达. 0x00 ...
- iphone下overflow失效问题的解决方法
overflow-y: auto; -webkit-overflow-scrolling:touch; /*加上这个让浏览器支持touch和自动滚动这样界面就可以滚动了*/
- Portal相关技术及架构
Portal以用户为中心,提供统一的用户登录,实现信息的集中访问,集成了办公商务一体的工作流环境.利用Portal技术,可以方便地将员工所需要的,来源于各种渠道的信息资料集成在一个统一的桌面视窗之内. ...
- BZOJ 3990 [SDOI 2015] 排序 解题报告
这个题哎呀...细节超级多... 首先,我猜了一个结论.如果有一种排序方案是可行的,假设这个方案是 $S$ . 那么我们把 $S$ 给任意重新排列之后,也必然可以构造出一组合法方案来. 于是我们就可以 ...
- Matlab心得及学习方法(不断更新)
Matlab心得及学习方法(不断更新) Matlab心得及学习方法(不断更新)P.S. 那些网上转载我的文章不写明出处的傻眼了吧?!老子更新了! 发现现在很多人(找工作的或者读博的)都想要学习或者正在 ...