hdu 3054 Fibonacci 找循环节的公式题
Fibonacci
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)
F1=1,F2=1,F3=2,F4=3,F5=5,
...
Fx = Fx-1+Fx-2
We want to know the Mth number which has K consecutive "0" at the end of Fx.
For example,
F15=610
It is the first number which has only one "0" at the end.
F300=222232244629420445529739893461909967206666939096499764990979600.
It is the second number which has two "0" at the end.
Of course, the Fx may be very large if M and K are big. So we only want to know the subscript of Fx (it means the "x" For a given M and K)
First line is the number of case x
The next x lines: Each line contains two integer number, K and M, divided by a space.
Print a integer number in a line, is the Mth number which has K consecutive 0s at the end of Fx. (You can believe the answer is smaller than 2^31);
1 1
2 2
2 5
300
900
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi (4*atan(1.0))
#define eps 1e-14
const int N=2e5+,M=4e6+,inf=1e9+,MOD=;
const ll INF=1e18+;
int a[]={,,,,,,,,,};
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
int k,m;
scanf("%d%d",&k,&m);
if(k==)
printf("%d\n",((m-)/*+)*a[k]+((m-)%)*a[k]);
else
printf("%d\n",((m-)/*+)*a[k]+((m-)%)*a[k]);
}
return ;
}
hdu 3054 Fibonacci 找循环节的公式题的更多相关文章
- hdu 3117 Fibonacci Numbers 矩阵快速幂+公式
斐波那契数列后四位可以用快速幂取模(模10000)算出.前四位要用公式推 HDU 3117 Fibonacci Numbers(矩阵快速幂+公式) f(n)=(((1+√5)/2)^n+((1-√5) ...
- 特征根法求通项+广义Fibonacci数列找循环节 - HDU 5451 Best Solver
Best Solver Problem's Link Mean: 给出x和M,求:(5+2√6)^(1+2x)的值.x<2^32,M<=46337. analyse: 这题需要用到高中的数 ...
- Hdu 5451 Best Solver (2015 ACM/ICPC Asia Regional Shenyang Online) 暴力找循环节 + 递推
题目链接: Hdu 5451 Best Solver 题目描述: 对于,给出x和mod,求y向下取整后取余mod的值为多少? 解题思路: x的取值为[1, 232],看到这个指数,我的心情是异常崩 ...
- 广义Fibonacci数列找循环节 学习笔记
遇到了2019ICPC南昌赛区的网络赛的一道题,fn=3*fn-1+2*fn-2,有多次询问求fn.总结起来其实就是在模P意义下,O(1)回答广义斐波那契额数列的第n项,可以说是一道模板题了. 这道题 ...
- 2016"百度之星" - 初赛(Astar Round2A)1001 All X(HDU5690)——找循环节|快速幂
一个由m个数字x组成的新数字,问其能否mod k等于c. 先提供第一种思路,找循环节.因为每次多一位数都是进行(t*10+x)mod k(这里是同余模的体现),因为x,k都确定,只要t再一样得到的答案 ...
- hdu 2837 Calculation 指数循环节套路题
Calculation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total ...
- 51 Nod 1035 最长的循环节 (此题还不是很懂,日后再看)
转自: https://blog.csdn.net/define_danmu_primer/article/details/52456763 51nod 1035 最长的循环节(无限小数的循环节) 2 ...
- HDU 6038 17多校1 Function(找循环节/环)
Problem Description You are given a permutation a from 0 to n−1 and a permutation b from 0 to m−1. D ...
- HDU 4786 Fibonacci Tree (2013成都1006题)
Fibonacci Tree Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)To ...
随机推荐
- 160922、配置:spring通过profile或@profile配置不同的环境(测试、开发、生产)
一.配置环境 applicationContext.xml中添加下边的内容(develop:开发环境,production:生产环境,test:测试环境) 注意:profile的定义一定要在文档的最下 ...
- React笔记_(5)_react语法4
ajax 数据应用场景 在真实的开发环境中,拿到了产品需求,第一件事不是逼着后台开发人员先完成,然后前端再介入开发,这样太浪费时间. 正确的做法是跟后端人员先商量好接口名称,请求参数,返回的数据格式等 ...
- linux curl用法详解
linux curl用法详解 curl的应用方式,一是可以直接通过命令行工具,另一种是利用libcurl库做上层的开发.本篇主要总结一下命令行工具的http相关的应用, 尤其是http下载方面 ...
- Spring项目启动时执行初始化方法
一.applicationContext.xml配置bean <bean id="sensitiveWordInitUtil" class ="com.hx.daz ...
- php函数:PHP pathinfo() 函数
pathinfo() 函数以数组的形式返回文件路径的信息. 语法 pathinfo(path,options) 参数 描述 path 必需.规定要检查的路径. process_sections 可选. ...
- ecshop后台增加栏目查询会员是否重复注册
ecshop的后台要查询哪些会员是否有重复注册时,可以利用特定的栏目来判断~ 譬如会员电话... 修改前请务必先备份下列档案!!! admin/users.php admin/templates/us ...
- greenplum集群安装
一.环境配置 1.地址分配 192.168.1.201 mdw master 192.168.1.202 sdw1 segment1 192.168.1.203 sdw2 segment2 2.创建用 ...
- PHP简单图片操作
<?php //PHP操作图片需打开配置文件中 extension=php_gd2.dll //================================================= ...
- 关闭用miniUI打开的窗口
miniUI打开的窗口用window.close关闭无效, 应该用window.CloseOwnerWindow();
- c# 财务数据编号的生辰
实现逻辑: 根据票号前戳+生成的6位数据编号=收据号(010+000001=010000001) 作废票号 将票号作废,插入到编号表中,以此下次在使用 作废票号使用 编号表中 现在只有2,当 ...