Triangle HDU
来源:互联网 发布:直播狗网络电视apk 编辑:程序博客网 时间:2024/06/10 14:32
Mr. Frog has n sticks, whose lengths are 1,2, 3⋯ ⋯n respectively. Wallice is a bad man, so he does not want Mr. Frog to form a triangle with three of the sticks here. He decides to steal some sticks! Output the minimal number of sticks he should steal so that Mr. Frog cannot form a triangle with
any three of the remaining sticks.
any three of the remaining sticks.
For each test case, there is only one line describing the given integer n (
3456
Case #1: 1Case #2: 1Case #3: 2
刚开始看有点蒙,后来猜了几组数据,看着眼熟,于是搞出来了;
上代码;
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;int T;int n;int vis[20];int main(){ scanf("%d", &T); vis[1] = vis[0] = 1; for(int i=2; i<=20; i++) { vis[i] = vis[i-1] + vis[i-2];//构建斐波那契 } for(int w=1; w<=T; w++) { scanf("%d", &n); printf("Case #%d: ",w); for(int i=1; i<=20; i++) {if(vis[i] > n){cout << n-i+1 << endl;break;} } } return 0;}
水波.
阅读全文
0 0
- Triangle HDU
- Triangle HDU
- HDU - 4324 Triangle LOVE
- hdu-4466-Triangle 数学题
- hdu 3817 Triangle
- hdu 4466 Triangle
- hdu 4324 - Triangle LOVE
- hdu 4142 Triangle 水题
- hdu 4466 Triangle (数学)
- hdu 4324 Triangle LOVE
- hdu 4466 Triangle
- HDU 4324 Triangle LOVE
- hdu 4324 Triangle LOVE
- HDU - 4466 Triangle
- HDU 4324 Triangle LOVE
- HDU Triangle LOVE
- hdu-3817-Triangle
- hdu 4324 Triangle LOVE
- 什么是 ROC AUC
- swagger ui
- 解决Ubuntu 16.10 搜狗输入法开机不自启的方法
- Eclipse启动Tomcat时,45秒超时解决方式
- java springMVC SSM 操作日志 4级别联动 文件管理 头像编辑 shiro redis
- Triangle HDU
- 基于MT7688/mt7628的wifi网络播放器
- 如何制作ppt
- 个人收集的mac破解软件免费下载(不断更新中)
- 有趣的算法问题12——跳跃游戏1(贪心算法)
- # 二分查找算法(Algorithms)第一章
- Spring+SpringMVC+MyBatis深入学习及搭建 —SpringMVC拦截器
- 【js 走进web】Web基础 网页的关节JS
- iOS 字符操作