hdoj KK's Steel 5620 (打表)
2016-02-25 09:43
274 查看
KK's Steel
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 464 Accepted Submission(s): 224
[align=left]Problem Description[/align]
Our lovely KK has a difficult mathematical problem:he has a N(1≤N≤1018) meters
steel,he will cut it into steels as many as possible,and he doesn't want any two of them be the same length or any three of them can form a triangle.
[align=left]Input[/align]
The first line of the input file contains an integer T(1≤T≤10),
which indicates the number of test cases.
Each test case contains one line including a integer N(1≤N≤1018),indicating
the length of the steel.
[align=left]Output[/align]
For each test case, output one line, an integer represent the maxiumum number of steels he can cut it into.
[align=left]Sample Input[/align]
1
6
[align=left]Sample Output[/align]
3
Hint1+2+3=6 but 1+2=3 They are all different and cannot make a triangle.
#include<stdio.h> #include<string.h> #include<algorithm> #define ll long long using namespace std; ll a[110]; ll s[110]; int main() { int t,i,j; ll n; a[1]=1;a[2]=1;a[3]=2; for(i=4;i<=100;i++) a[i]=a[i-1]+a[i-2]; for(i=2;i<=100;i++) s[i]=s[i-1]+a[i]; scanf("%d",&t); while(t--) { scanf("%lld",&n); for(i=2;i<100;i++) { if(s[i]>=n) break; } if(s[i]==n) printf("%d\n",i-1); else printf("%d\n",i-2); } return 0; }
相关文章推荐
- 四种生成和解析XML文档的方法详解(介绍+优缺点比较+示例)
- 可穿戴设备开发者大会
- map删除元素时防止迭代器失效的例子
- Hadoop2.X学习笔记--搭建
- STM32中断向量表偏移量0x200详解
- C++ 中使用json
- VC/MFC如何设置对话框背景颜色
- Windows PowerShell中scp命令
- [FastDFS] tracker报错, ERROR - file: tracker_nio.c, line: 214, recv timeout
- 归档日志
- linux-shell-#@!...
- 尝试在PYTHON中调用StanfordNLP,具体代码如下
- Python压缩多个属于不同驱动器的文件夹至同一个zip文件
- 【设计模式】策略模式
- Linux下执行可执行文件
- PATB1020
- 随机数生成算法,每一次生成都不一样
- Markdown 常用语法简单学习
- 单机数据库调整redo log日志大小
- iOS内存管理之:引用计数、ARC、自动释放池autoreleasepool和便捷方法之间的关系