博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu3054(斐波那契。。。。找规律)
阅读量:5054 次
发布时间:2019-06-12

本文共 1636 字,大约阅读时间需要 5 分钟。

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

打表。。。。这题代码量比较少,但还是很考验找规律能力的,而且!!!

哭眼力必须好啊!

下面是我的打表代码,输入n代表末尾n个0:

#include 
using namespace std;int pp(int n){ int ans=1; for(int i=0;i
>n) { int p0=pp(n),p1=pp(n+1),t=1; f[1]=1; for(int i=2;i<100000000;i++) { f[i]=(f[i-1]+f[i-2])%p1; if(f[i]%p0==0&&f[i]!=0) { cout<
<<"th feibo "<
<<"th number"<
运行完打表代码之后会发现1,3,4,5,6,7,……都是到第9个数增量是有一个变化!

而2是到第4个数增量有了变化!(说实话真的很难仔细一直看到第9个!!能看出2都很不错了哭

然后就是找规律了,这个自己都能写的!

#include 
#include
#include
using namespace std;int pp(int n){ int ans=1; for(int i=0;i

转载于:https://www.cnblogs.com/martinue/p/5490513.html

你可能感兴趣的文章
BZOJ.3998.[TJOI2015]弦论(后缀自动机)
查看>>
localStorage登录页记住密码(艺博会)
查看>>
JSON.parse()与JSON.stringify()的区别
查看>>
json对象的获取
查看>>
php读取文件内容的三种方式(转)
查看>>
hadoop数据备份
查看>>
二分图匹配 学习笔记
查看>>
poj 2154:Color【polya计数,Euler函数】
查看>>
正则表达式
查看>>
SpringMVC框架学习笔记(2)——使用注解开发SpringMVC
查看>>
深入理解递归函数的调用过程
查看>>
《在C#中实现Socket端口复用》 以及《 UDP 一个封锁操作被对 WSACancelBlockingCall 的调用中断。》问题...
查看>>
PDF格式的“在线阅读”和“下载”
查看>>
无耻之徒(美版)第七季/全集Shameless US迅雷下载
查看>>
svn cleanup failed–previous operation has not finished; run cleanup if it was interrupted
查看>>
Webpack4 学习笔记四 暴露全局变量、externals
查看>>
CF1005F Berland and the Shortest Paths
查看>>
vscode点击ctrl键报错Request textDocument/definition failed.
查看>>
POJ 3368 Frequent values (RMQ,4级)
查看>>
java 练习题3
查看>>