KK's Steel
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 350 Accepted Submission(s): 166
Each test case contains one line including a integer N(1≤N≤1018),indicating the length of the steel.
1+2+3=6 but 1+2=3 They are all different and cannot make a triangle.
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#define MAX 100100
#define INF 0x3f3f3f
#define LL long long
using namespace std;
LL fb[10010];
LL f[1001];
void biao()
{
LL i,j;
fb[1]=1;
fb[2]=2;
for(i=3;i<120;i++)
fb[i]=fb[i-1]+fb[i-2];
f[1]=fb[1];
for(i=2;i<120;i++)
f[i]=f[i-1]+fb[i];
}
int main()
{
int t,i,j;
LL n;
biao();
scanf("%d",&t);
while(t--)
{
scanf("%lld",&n);
for(i=1;i<120;i++)
{
if(n==f[i])
{
printf("%d\n",i);
break;
}
if(n<f[i])
{
printf("%d\n",i-1);
break;
}
}
}
return 0;
}
BestCoder Round #71 (div.2) (hdu 5620 菲波那切数列变形)的更多相关文章
-
菲波那切数列(Fibonacci Number)
什么是菲波那切数列?自己google一下,面试题里面经常遇到,考试递归算法用的. 在菲波那切数列中用递归不太好.第三种算法最好. 第一 递归算法最差了,不想说.测试一下,当N=6000时,半天出不来数 ...
-
BestCoder Round #71 (div.2) (hdu 5621)
KK's Point Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
-
BestCoder Round #71 (div.2)
数学 1001 KK's Steel 类似斐波那契求和 #include <cstdio> #include <cstring> #include <algorithm& ...
-
BestCoder Round #52 (div.2) HDU 5418 Victor and World (DP+状态压缩)
[题目链接]:pid=5418">click here~~ [题目大意]: 问题描写叙述 经过多年的努力,Victor最终考到了飞行驾照. 为了庆祝这件事,他决定给自己买一架飞机然后环 ...
-
php实现菲波那切数列和杨辉三角
1.递归 显示斐波那契数列 <?PHP function recursion($num){ //判断是否小于0 if($ ...
-
hdu 5636 搜索 BestCoder Round #74 (div.2)
Shortest Path Accepts: 40 Submissions: 610 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: ...
-
BestCoder Round #69 (div.2) Baby Ming and Weight lifting(hdu 5610)
Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K ( ...
-
BestCoder Round #68 (div.2) tree(hdu 5606)
tree Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submis ...
-
hdu5634 BestCoder Round #73 (div.1)
Rikka with Phi Accepts: 5 Submissions: 66 Time Limit: 16000/8000 MS (Java/Others) Memory Limit: ...
随机推荐
-
[LeetCode] Shuffle an Array 数组洗牌
Shuffle a set of numbers without duplicates. Example: // Init an array with set 1, 2, and 3. int[] n ...
-
BAYSY2 的LVDS引脚 笔记
差分引脚标号说明: 'L' 代表该引脚属于差分引脚 'xx' 两位整型数,在每一 bank 的独特标记 'y' 表示正向 还是 反向,同时要注意输入输出方向 ‘#’ 0~3,代表 bank0~bank ...
-
node递归属性目录结构
要求,读取结束后才能输出所有文件 var fs = require('fs');var path = require('path'); var list = [];var count = 0;func ...
-
Win7下JDK环境变量的设置
JDK并不像Microsoft阵营vs那样智能,安装好后所有的东西都给你配置好了,我们还没需要手动配置很多东西 首先说为什么要配置JDK的环境变量在任何路径下识别java命令和java类 配置分为2个 ...
-
Linux TC (traffic control)
在着手学习TC采用如下单位来描述带宽: mbps = 1024 kbps = 1024 * 1024 bps => byte/s mbit = 1024 kbit => kilo bit/ ...
-
Qt5.3企业版和开源版功能区别
一: Charts Charts是QT提供的图表模块.他提供了非常简便的APIs来绘制令人惊叹的Line, Spline,Area,Scatter,Pie,Donut,Bar,Polar和Box-an ...
-
android okhttp的使用
OkHttpClient client = new OkHttpClient(); String url = ""; Request request = new Request.B ...
-
Python中的对象行为与特殊方法(一)对象的创建与销毁
Python中类调用__new__()类方法来创建实例,调用__init__()方法来初始化对象,对象的销毁则调用__del__()方法. __new__()方法第一个参数为类cls,通常返回cls的 ...
-
面向对象的轮播js
1.自执行函数的前后要加分号 案例: ;(function(){})(); 2.面向对象的最大优势节省了许多内存 正式开写面向对象的轮播: <!DOCTYPE html> <html ...
-
VFS: Cannot open root device ";nfs"; or unknown-block(0,255)错误的解决
1. 解决办法:在内核配置时候文件系统中选中Root file system on NFS