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 ...
随机推荐
- Java知识总结--三大框架
1 应用服务器有哪些:weblogic,jboss,tomcat 2 Hibernate优于JDBC的地方 1)对jdbc访问数据库进行了封装,简化了数据访问层的重复代码 2)Hibernate 操作 ...
- 在网页中插入qq连接
<a href="tencent://message/?uin=这里写qq号 &Site=这里随便七个名字 &Menu=要为yes">显示出来的名字&l ...
- Asp.net Gridview导出Excel
前台页面放一个GridView什么的就不说了,要注意的是在 <%@ Page Language="C#" AutoEventWireup="true" C ...
- AOP(以MVC中的过滤器为例)
MVC里面的Filter public class AOPFilterAttribute : ActionFilterAttribute, IExceptionFilter { public void ...
- 关于ASE日志空间示数不正常的解决办法
最近某系统的ASE数据库出现了异常,经过各种努力,终于把数据库正常又起起来了.但是经过检查,发现在查看剩余日志空间的时候(sp_helpsegment 'logsegment'),发现显示出来 ...
- 四大主流云平台对比--CloudStack, Eucalyptus, vCloud Director和OpenStack。
我迟早可能都要进入的领域,提前温习... 还有KVM,ESXI,API,XEN之间的术语和关系,也要心中有数.. ~~~~~~~~~~~~~~~~~~~ 云计算在如今的IT界一直是一个最热门的话题,鉴 ...
- Maven引入依赖后自动下载并关联源码(Source)
好多用 Maven 的时候会遇到这样一个棘手的问题: 就是添加依赖后由于没有下载并关联源码,导致自动提示无法出现正确的方法名,而且不安装反编译器的情况下不能进入方法内部看具体实现 . 其实 eclip ...
- [jobdu]扑克牌顺子
一开始看到题还以为要DFS还是BFS,后来发现完全不用.排个序,然后看看大小王能不能弥补缺口就行,但后来又发现还要排除有相同大小牌的情况. #include <iostream> #inc ...
- Linux网络地址转换分析
Linux网络地址转换分析 地址转换用来改变源/目的端口,是netfilter的一部分,也是通过hook点上注册相应的结构来工作. Nat注册的hook点和conntrack相同,只是优先级不同,数据 ...
- Linux内核中流量控制
linux内核中提供了流量控制的相关处理功能,相关代码在net/sched目录下:而应用层上的控制是通过iproute2软件包中的tc来实现, tc和sched的关系就好象iptables和netfi ...