hdu 5167 Fibonacci(预处理)】的更多相关文章

Problem Description Following is the recursive definition of Fibonacci sequence: Fi=⎧⎩⎨01Fi−1+Fi−2i = 0i = 1i > 1 Now we need to check whether a number can be expressed as the product of numbers in the Fibonacci sequence.   Input There is a number T …
题目链接: hdu: http://acm.hdu.edu.cn/showproblem.php?pid=5167 题意: 给你一个x,判断x能不能由斐波那契数列中的数相乘得到(一个数可以重复使用) 题解: 1.筛法 首先,小于10^9的斐波那契数很少,就42个(不包括0,1),对于给定的x能同时成为它的因子的斐波那契数更少,所以可以暴力考虑所有能整除x的斐波那契数组成的集合的所有子集. 但是,对于每个子集做筛法的时候必须从大的数开始筛(质因数分解可以随便筛是因为一个数的质因数分解具有唯一性,但…
Fibonacci Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description Following is the recursive definition of Fibonacci sequence: Fi=⎧⎩⎨01Fi−1+Fi−2i = 0i = 1i > 1 Now we need to check whether a number can…
HDU 3117 Fibonacci Numbers(斐波那契前后四位,打表+取对+矩阵高速幂) ACM 题目地址:HDU 3117 Fibonacci Numbers 题意:  求第n个斐波那契数的前四位和后四位.  不足8位直接输出. 分析:  前四位有另外一题HDU 1568,用取对的方法来做的.  后四位能够用矩阵高速幂,MOD设成10000即可了. 代码: /* * Author: illuz <iilluzen[at]gmail.com> * Blog: http://blog.c…
斐波那契数列后四位可以用快速幂取模(模10000)算出.前四位要用公式推 HDU 3117 Fibonacci Numbers(矩阵快速幂+公式) f(n)=(((1+√5)/2)^n+((1-√5)/2)^n)/√5 假设F[n]可以表示成 t * 10^k(t是一个小数),那么对于F[n]取对数log10,答案就为log10 t + K,此时很明显log10 t<1,于是我们去除整数部分,就得到了log10 t 再用pow(10,log10 t)我们就还原回了t.将t×1000就得到了F[n…
Interesting Fibonacci Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 665    Accepted Submission(s): 114 Problem Description In mathematics, the Fibonacci numbers are a sequence of numbers named…
这道题其实也是水题来的,求Fibonacci数的前4位和后4位,在n==40这里分界开.后4位不难求,因为n达到了10^18的规模,所以只能用矩阵快速幂来求了,但在输出后4位的时候一定要注意前导0的处理(我就是在这里wa了一发,也是看了看别人的代码才发现的). 前4位的话稍微有点难处理,我一开始就在想该怎么处理 log10(f(n)) 呢?把f[n]= f[n-1]+f[n-2]? 不行,log对+运算没法展开,我找了好久也没能找到什么能让f[n]展开成相乘或者幂的形式,上网搜了下题解,才发现别…
http://acm.hdu.edu.cn/showproblem.php?pid=4786 Fibonacci Tree Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 49    Accepted Submission(s): 26 Problem Description Coach Pang is interested in Fi…
http://acm.hdu.edu.cn/showproblem.php?pid=1021 Fibonacci Again Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 29201    Accepted Submission(s): 14148 Problem Description There are another kind…
Fibonacci Tree 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=4786 Description Coach Pang is interested in Fibonacci numbers while Uncle Yang wants him to do some research on Spanning Tree. So Coach Pang decides to solve the following problem: Consi…