uva 573 The Snail
来源:互联网 发布:淘宝不能重新激活店铺 编辑:程序博客网 时间:2024/04/27 14:11
题意:有给测试数据,H,U,D,F。H表示墙的高度,U表示白天能爬多少,D表示晚上下降多少,F表示疲劳程序(表示每天爬的高度都会减少H*F%)。注意,蜗牛是不会往下爬的,白天能爬的距离小于0,那么它是会保持原来的高度,然后晚上下降D。要求输出,在第几天爬出,或者在第几天掉回原点。
数据的范围都在100内。
直接模拟了,不过注意,回到原点,是高度小于0。
#include <iostream>#include <cstdio>#include <cstring>using namespace std;int main(){ double H,U,D,F; while(scanf("%lf%lf%lf%lf",&H,&U,&D,&F)!=EOF) { if(H==0&&U==0&&D==0&&F==0) break; double height=0,down=U*F/100.0; int cnt=1;bool flag=false; while(1) { if(U>0) height+=U; if(height>H) {printf("success on day %d\n",cnt);break;} height-=D;U-=down; if(height<0) {printf("failure on day %d\n",cnt);break;} cnt++; } } return 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
- Linux驱动之设备模型(7)
- C#datagridview回车替代TAB键切换焦点
- 历史使命
- OT源代码的分析,OrtHello 迟早攻破你 (二)OT的基本属性和基本流程
- 由Spring管理的Struts2的Action的单实例问题
- uva 573 The Snail
- Linux驱动之设备模型(8)
- Screen — A must for SSH
- 数据结构之冒泡排序
- C#datagridview自动编号
- Activity通过bindService启动Service后Activity和Service之间的通信!
- string和exception在vc6.0中的使用
- 使用Contact数据模型来批量插入联系人(下)
- 农妇