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 ...
随机推荐
- Chrome控制台函数
你是光你是电,你是唯一的神话. Chrome的出现简直拯救了广大前端,不仅仅是因为其V8引擎的速度,更是因为其强大的控制台.为调试前端提供了强大的武器. 当然Firefox下的firebug也很强大, ...
- windows 7 64bit 下apache php mysql 环境配置
在64位环境下安装apache,php和配置过程 准备好安装包.(64位版本) Apache 下载地址:http://www.apachelounge.com/download/ Php 下载地址:h ...
- python【第五篇】常用模块学习
一.主要内容 模块介绍 time &datetime模块 random os sys shutil json & pickle shelve xml处理 yaml处理 configpa ...
- ORA-12012 error on auto execute of job 8887
*** ACTION NAME:(AUTO_SPACE_ADVISOR_JOB) -- ::58.046 *** MODULE NAME:(DBMS_SCHEDULER) -- ::58.046 ** ...
- python中functools.wraps装饰器的作用
functools.wraps装饰器用于显示被包裹的函数的名称 import functools def node(func): #@functools.wraps(func) def wrapped ...
- CentOS 6.6x64下编译gcc-4.7.4
最近使用老版本的gcc发现一些问题,于是想尝试升级. 看了一些教程之后进行尝试,发现各类教程均会有一些小问题,于是在此记录一下本人的过程. 编译过程中参考的文章有如下几篇,在此表示感谢: http:/ ...
- EL四大作用域 9个jsp对象有效范围 及 对应的类
java中request,session,application的作用范围 page,request,session,application四者的作用范围: page的作用范围是当前页面:对应El表达 ...
- POJ3613 Cow Relays [矩阵乘法 floyd类似]
Cow Relays Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7335 Accepted: 2878 Descri ...
- 当页面编辑或运行提交时,出现“从客户端中检测到有潜在危险的request.form值”问题,该怎么办呢?
最近在学习highcharts时,关于其中的导出功能,本来是想把导出的图片存放在本地,发现只有在电脑联网的情况下才可以一下导出图片,后来查阅了一番资料,才发现highcharts中的导出默认的官网服务 ...
- routes.IgnoreRoute("{resource}.axd/{*pathInfo}")作用
{resource}.axd 表示后缀名为.axd所有资源 如webresource.axd{*pathInfo} 表示所有路径 作用:使路由系统忽略处理ASP.NET的Web资源文件(WebReso ...