hdu-5620
来源:互联网 发布:四大审计软件 编辑:程序博客网 时间:2024/04/28 05:24
KK's Steel
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 218 Accepted Submission(s): 103
Problem Description
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.
Input
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 integerN(1≤N≤1018) ,indicating the length of the steel.
Each test case contains one line including a integer
Output
For each test case, output one line, an integer represent the maxiumum number of steels he can cut it into.
Sample Input
16
Sample Output
3Hint1+2+3=6 but 1+2=3 They are all different and cannot make a triangle.
Source
BestCoder Round #71 (div.2)
解体思路:在bc上提交时就WA了,在杭电上找到题目重新提交就过了,真不科学.
代码如下:
#include<stdio.h>int main(){long long n,a,b,c,sum,ans;int t;scanf("%d",&t);while(t--){scanf("%lld",&n);a=1;b=2;sum=a+b;ans=1;if(n==1||n==2)printf("1\n");else{ while(sum<=n){ ans++; c=a+b; sum+=c;a=b; b=c; } printf("%lld\n",ans);}}return 0;}
0 0
- hdu-5620
- hdu 5620
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- poj 2796 Feel Good 单调栈/dp
- 假期小算法--堆排序(啊哈算法)
- 打表法判断素数(掌握)
- 【番外篇】Java 回调
- mac下开发环境的常见问题解决方法
- hdu-5620
- ACM解题总结-hihoCoder1137
- struts2文件上传下载(含中文编码问题)
- android之WindowManager学习
- vxWorks的双向链表示例
- leetcode235题 题解 翻译 C语言版 Python版
- sublime Text 3 使用总结
- jQuery简单图片提示
- iPhone陀螺仪