UVA 573 The Snail
来源:互联网 发布:网络电视不更新怎么办 编辑:程序博客网 时间:2024/04/27 20:22
UVA-573
题意:蜗牛白天往上爬,晚上往下滑,并且每天往上爬的距离会按第一天的一定比例递减,求蜗牛能不能爬出去,能爬出去是在第几天,不能的话在第几天触底。
解题思路:暴力模拟,白天爬完判断出没出去,晚上下滑判断触没触底,爬出去的条件是爬的高度 > h。触底条件是爬的高度 < 0。白天爬高的距离最小是0,不会负的。
/************************************************************************* > File Name: UVA-573.cpp > Author: Narsh > > Created Time: 2016年07月14日 星期四 15时12分33秒 ************************************************************************/#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>using namespace std;int h,u,d,f;int main () { while (scanf("%d%d%d%d",&h,&u,&d,&f) && h+u+d+f) { double l = u, now = u; int day=0; while (l >= 0) { day++; if ( l > h ) break; l -= d; now = now - (double) f/100.0 * (u*1.00); if (now < 0) now = 0; if (l < 0) break; l += now; } if (l > h) printf("success on day %d\n",day); else printf("failure on day %d\n",day); }}
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
- 原型对象 原型相关问题
- [2016/7/14]一天不写东西就难受
- C++之多态
- instance of,isInstance,isAssignableFrom
- 字符串组合问题
- UVA 573 The Snail
- kali搜集工具之CDPSnarf
- 7月13号面试小结
- Poj - 1845 - Sumdiv
- Android线程池使用详解
- ul li 实例
- Code[vs]3287【NOIP2013提高组】【7.13考试第四题】货车运输
- Linux学习笔记--搜索命令
- description