UVA - 573 The Snail
来源:互联网 发布:数据透视表高级技巧 编辑:程序博客网 时间:2024/04/28 04:17
题意:
一个蜗牛在一个6英尺的井中,在日出的时候可以向上爬3英尺,但是在晚会下降1英尺。蜗牛有10%疲劳的因素,这意味着在每个连续天蜗牛上爬比前一天少0.1 * 3 = 0.3英尺,在第几天蜗牛可以离开井?
谨记:
蜗牛每天的爬行距离必须要大于等于0;如果小于的话就要赋值为0;
#include<stdio.h>#include<iostream>using namespace std;int main(){int h,u,d,f;double he,up,down,fl;while(scanf("%d%d%d%d",&h,&u,&d,&f)){if(h == 0 && u == 0)break;up = u;down = d;int day = 0;fl = 1.0*f/100*up;he = 0;while(he >= 0 && he <= h){day ++ ;he += up;if(he > h)break;he -= down ;up -= fl;if(up < 0)up = 0;}if(he > h)printf("success on day %d\n",day);elseprintf("failure on day %d\n",day);}return 0;}
0 0
- UVa 573 - The Snail
- uva - 573 the snail
- uva 573 The Snail
- uva 573 - The Snail
- UVa 573 - The Snail
- UVa 573 - The Snail
- UVa 573 - The Snail
- UVA 573 The Snail
- uva 573 - The Snail
- uva 573 The Snail
- UVA 573 The Snail
- UVa 573 - The Snail
- Uva 573 The Snail
- UVA - 573 The Snail
- uva 573 The Snail
- UVA - 573 The Snail
- UVa:573 - The Snail
- uva 573 The Snail
- 动态库和静态库
- jenkins权限管理配置
- Android Studio使用说明
- Java JVM使用哪种编码格式
- Given a tree, find the node with the minimum sum of distances to other nodes
- UVA - 573 The Snail
- Jenkins权限设置误操作后的补救
- android学习--TabHost选项卡组件
- 【转】CnLevelEdtior0.1版本Tag一下, 小谈OgreMax
- 五类直连线做法
- Spring笔记(6)-----------注入参数详解
- 浅谈函数应用
- redhat
- Ubuntu系统的备份与还原与修复启动项