Fibonacci

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)

Problem Description
We know the Fibonacci Sequence

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)

 
Input
Input includes multiple cases.

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.

 
Output
For each case:

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);

 
Sample Input
3
1 1
2 2
2 5
 
Sample Output
15
300
900
 
Source
#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 找循环节的公式题的更多相关文章

  1. hdu 3117 Fibonacci Numbers 矩阵快速幂+公式

    斐波那契数列后四位可以用快速幂取模(模10000)算出.前四位要用公式推 HDU 3117 Fibonacci Numbers(矩阵快速幂+公式) f(n)=(((1+√5)/2)^n+((1-√5) ...

  2. 特征根法求通项+广义Fibonacci数列找循环节 - HDU 5451 Best Solver

    Best Solver Problem's Link Mean: 给出x和M,求:(5+2√6)^(1+2x)的值.x<2^32,M<=46337. analyse: 这题需要用到高中的数 ...

  3. Hdu 5451 Best Solver (2015 ACM/ICPC Asia Regional Shenyang Online) 暴力找循环节 + 递推

    题目链接: Hdu  5451  Best Solver 题目描述: 对于,给出x和mod,求y向下取整后取余mod的值为多少? 解题思路: x的取值为[1, 232],看到这个指数,我的心情是异常崩 ...

  4. 广义Fibonacci数列找循环节 学习笔记

    遇到了2019ICPC南昌赛区的网络赛的一道题,fn=3*fn-1+2*fn-2,有多次询问求fn.总结起来其实就是在模P意义下,O(1)回答广义斐波那契额数列的第n项,可以说是一道模板题了. 这道题 ...

  5. 2016"百度之星" - 初赛(Astar Round2A)1001 All X(HDU5690)——找循环节|快速幂

    一个由m个数字x组成的新数字,问其能否mod k等于c. 先提供第一种思路,找循环节.因为每次多一位数都是进行(t*10+x)mod k(这里是同余模的体现),因为x,k都确定,只要t再一样得到的答案 ...

  6. hdu 2837 Calculation 指数循环节套路题

    Calculation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  7. 51 Nod 1035 最长的循环节 (此题还不是很懂,日后再看)

    转自: https://blog.csdn.net/define_danmu_primer/article/details/52456763 51nod 1035 最长的循环节(无限小数的循环节) 2 ...

  8. 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 ...

  9. HDU 4786 Fibonacci Tree (2013成都1006题)

    Fibonacci Tree Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)To ...

随机推荐

  1. 精通 JS正则表达式

    一.正则表达式可以: 测试字符串的某个模式.例如,可以对一个输入字符串进行测试,看在该字符串是否存在一个电话号码模式或一个信用卡号码模式.这称为数据有效性验证 替换文本.可以在文档中使用一个正则表达式 ...

  2. linux问题汇总---如何生成密钥对

    准备:2台机器,ip分别为:192.168.0.195     192.168.1.210目的:通过195ssh远程访问210.无需输入密码 1.首先在195上生成密钥对.#cd /root/.ssh ...

  3. 如何杀掉D状态的进程?[zt]【转】

    转自:http://blog.csdn.net/chinalinuxzend/article/details/4288791 [-] 如何杀掉D状态的进程zt 相关博文   原贴:http://www ...

  4. 安装keepalived

    主机名  网络IP                     VIPnode1 192.168.2.161     192.168.2.165node2 192.168.2.162 [root@node ...

  5. 在JS函数中执行C#中的函数、字段

    1.调用字段 cs文件的代码: ; protected void Page_Load(object sender, EventArgs e) { id = ; } js页面的代码: function ...

  6. rtc关机闹钟6 AlarmManagerService研究

    这个是 private void setLocked(int type, long when) { if (mNativeData != 0) {            // The kernel n ...

  7. C#委托之泛型

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cons ...

  8. 一个通用的DAO模型实现增删改查

    首先三个架包: mysql-connector-java-jar commons-dbcp-1.4jar commons-pool-1.5.5jar 导进去: (从上往下一次调用,实现功能) ---- ...

  9. 使用Window Live Writer写博客

    1.打开“日志账户”—>“日志选项”. 2.点击“更新账户信息”. 3.输入博客地址,用户名和密码,点击“下一步”. 4.耐心等待片刻... 5.设置“日志昵称”,点击“完成”. 这样就大功告成 ...

  10. 2016年10月11日 星期二 --出埃及记 Exodus 18:22

    2016年10月11日 星期二 --出埃及记 Exodus 18:22 Have them serve as judges for the people at all times, but have ...