题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1105 题解:这题你会巧妙的发现 1-(1),2-(10),3-(100),5-(1000),8-(10000),13-(100000) 刚好是一个斐波那契数列,当然这不是巧合.因为n可以有n-2,n-4,n-6....或者由n-3,n-5,n-7...也就是说可以由前面那些组成.所以可以先用斐波那契找一下大致位置人后再利用贪心补位即可. #include <iostream>…
题目:输出第 n 个斐波纳契数(Fibonacci) 方法一.简单递归 这个就不说了,小n怡情,大n伤身啊……当n=40的时候,就明显感觉到卡了,不是一般的慢. //输出第n个 Fibonacci 数 #include <iostream> using namespace std; long long Fibonacci(int n) { ) ; ) + Fibonacci(n-); } int main() { int n; while(cin>>n, n) cout<&l…
Number Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 187893    Accepted Submission(s): 46820 Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A…
python实现斐波那契数列的三种方法 """ 斐波那契数列 0,1,1,2,3,5,8,13,21,... """ # 方法一:while循环 def fibonaccise(number): """ 求数字number以内的斐波那契数列 """ a = 0 b = 1 list_number = [a] while b < number: list_number.append(…
#include<bits/stdc++.h> using namespace std; ]; ]; ; int main() { dp[] = ; scanf(); ); ; i<=N; ++i) { if(s[i] == 'm' || s[i] == 'w') { puts("); ; } dp[i] = dp[i-]; &&(s[i] == ]==]=='u')) dp[i] = (dp[i-]+dp[i-])%MOD; } printf("%d…
B. Fi Binary Number     A Fi-binary number is a number that contains only 0 and 1. It does not contain any leading 0. And also it does not contain 2 consecutive 1. The first few such number are 1, 10, 100, 101, 1000, 1001, 1010, 10000, 10001, 10010,…
http://acm.hdu.edu.cn/showproblem.php?pid=6198 F0=0,F1=1的斐波那契数列. 给定K,问最小的不能被k个数组合而成的数是什么. 赛后才突然醒悟,只要间隔着取k+1个数,显然根据斐波那契数列规律是不存在把其中两个数相加的结果又出现在数列中的情况(有特别的看下面),不就不会被组合出来了么? 这里有1 3 8...这种和1 2 5 13...两种,但因为后者任意一位的1,2可以被转化为3,这是唯一一种特例,所以我们采用前者.构造矩阵快速幂一下. #i…
1225. Flags Time limit: 1.0 secondMemory limit: 64 MB On the Day of the Flag of Russia a shop-owner decided to decorate the show-window of his shop with textile stripes of white, blue and red colors. He wants to satisfy the following conditions: Stri…
The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is, F(0) = 0,   F(1) = 1 F(N) = F(N - 1) + F(N - 2), for N > 1. Given…
I. Interesting Integers 传送门 应该是叫思维题吧,反正敲一下脑壳才知道自己哪里写错了.要敢于暴力. 这个题的题意就是给你一个数,让你逆推出递推的最开始的两个数(假设一开始的两个数为x和y),而且要求x<=y. 通过找规律可以发现,这个题就是求解a*x+b*y=k这个方程的x和y的值,并且要x和y为最小满足条件的解.可以找规律出一个公式fi[i]*x+(fi[i-1]+fi[i])*y=n.因为不知道n具体是在第几步推出来的,所以for循环跑一遍预处理出来的斐波那契数列(存…