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 ...
随机推荐
- s3c2440 lcd 显示图片裸机程序
因为前面的裸机程序非常的简单,就不写博了. 程序的流程: 1,初始化C SP 2,关看门狗 3,初始化SDRAM 4,读出 NAND FLASH 中的 包含图片的程式放到SDRAM里面 5,跳转到SD ...
- oracle SGA详解
SGA(System Global Area)系统全局区.这是一个非常庞大的内存区间,也是为什么开启oracle之后占用了很大内存的原因. SGA分为不同的池,我们可以通过视图v$sgastat查看, ...
- 2016年最好的15个Web设计和开发工具
1.ai2html ai2html是适用于Adobe Illustrator的开源脚本,可以转换Illustrator文件为html和css. 官方网站:http://ai2html.org/ 2.A ...
- 关于JDK,tomcat,MyEclipse的配置
1.下载安装JDK 在自定义安装路径时,jdk和之后的jre文件夹是属于平行结构,我的安装路径为:D:\jdk\jdk1.6.0_43和D:\jdk\jre6 然后是对环境变量的配置, 计算机→属性→ ...
- 定义提示符 PS1 PS4
PS1,如:[xiluhua@vm-xiluhua][~]$ # prompt PS1 export PATH BLUE=$(tput setaf ) PURPLE=$(tput setaf ) YE ...
- Oracle将表keep到内存
一.引言: 有时候一些基础表需要非常的频繁访问,尤其是在一些循环中,对该表中的访问速度将变的非常重要.为了提高系统的处理性能,可以考虑将一些表及索引读取并保存到内存中. 二.关于keep内存的几个参数 ...
- linux进程调度方法(SCHED_OTHER,SCHED_FIFO,SCHED_RR)
转于:http://blog.csdn.net/maray/article/details/2900689 Linux内核的三种调度方法: 1,SCHED_OTHER 分时调度策略, 2,SCHED_ ...
- css常用命名规则
(一)常用的CSS命名规则 头:header 内容:content/container 尾:footer 导航:nav 侧栏:sidebar 栏目:column 页面外围控制整体布局宽度:wrappe ...
- linux中利用awk对数组进行排序
数组 在排序前需要对数组有所了解,数组是用于存储一系列值得变量,这些值之间通常是由联系的,可通过索引来访问数组的值,索引需要用括号括起来,基本格式如下: array[index]=value awk数 ...
- linux修改mac地址
先禁用网卡ifconfig eth0 down 再用ifconfig eth0 hw ether 新地址 这样就可以了 要想永久修改的话,在/etc/rc.d/rc.local里加上下面三句(/etc ...