UVa 573 - The Snail
题目大意:有一只蜗牛位于深一个深度为h米的井底,它白天向上爬u米,晚上向下滑d米,由于疲劳原因,蜗牛白天爬的高度会比上一天少f%(总是相对于第一天),如果白天爬的高度小于0,那么这天它就不再向上爬,问这只蜗牛在几天爬出井口或滑下井底。
很直接的题,就是纠结于当蜗牛白天不爬的时候,下一天它是继续不爬还是向上爬u米,这个题的意思应该是以后白天都不再向上爬。还有就是注意边界,成功(>h)和失败(<0)。
#include <cstdio> int main()
{
#ifdef LOCAL
freopen("in", "r", stdin);
#endif
int height, up, down, f;
while (scanf("%d%d%d%d", &height, &up, &down, &f) && height)
{
double diff = up * f / 100.0;
double pos = , dis = up; // dis is the distance of climb on current day
int day = ;
while (true)
{
day++;
pos += dis;
if (pos > height)
{
printf("success on day %d\n", day);
break;
}
if (dis > ) dis -= diff;
if (dis < ) dis = ;
pos -= down;
if (pos < )
{
printf("failure on day %d\n", day);
break;
}
}
}
return ;
}
本来说要练习DP的,可是忽然又想系统的看一下Competitive Programming 1,发现上面的分类还是不错的,比《算法竞赛入门经典》更细,于是就从头开始了...,是不是太三心二意了?-_-|| 本来是打算好好做白书的习题的,只是那本书就给了一大堆习题,也没分类,算了,结合着看吧,希望最后不要什么都没干成...先从starred problems的开始吧,剩下的题可以以后在做,毕竟原来也做了一些水题了,现在主要想在算法方面提高一下,而不是去刷排名。
UVa 573 - The Snail的更多相关文章
- HDOJ 1302(UVa 573) The Snail(蜗牛爬井)
Problem Description A snail is at the bottom of a 6-foot well and wants to climb to the top. The sna ...
- UVA 573 (13.08.06)
The Snail A snail is at the bottom of a 6-foot well and wants to climb to the top.The snail can cl ...
- 573 The Snail(蜗牛)
The Snail A snail is at the bottom of a 6-foot well and wants to climb to the top. The snail can ...
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- Volume 1. Maths - Misc
113 - Power of Cryptography import java.math.BigInteger; import java.util.Scanner; public class Main ...
- uva 1354 Mobile Computing ——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5
- UVA 10564 Paths through the Hourglass[DP 打印]
UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...
- UVA 11404 Palindromic Subsequence[DP LCS 打印]
UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...
- UVA&&POJ离散概率与数学期望入门练习[4]
POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...
随机推荐
- UVA 11853 Paintball ——(dfs+圆交判定)
题意:给出一个1000*1000大小的矩阵,里面有若干圆,表示障碍物,现在要找出从左边到右边的一条通路,输出入口和出口的坐标,如果有多答案,输出y值最大的答案. 分析:从与上面相连的圆开始dfs,每次 ...
- Changing a remote's URL
原文: https://help.github.com/articles/changing-a-remote-s-url/ Changing a remote's URL MAC WINDOWS LI ...
- ajax 跨域请求资源问题
其实相当的简单:只需要在服务端设置一下响应头: header("Access-Control-Allow-Origin: *");就可以了!! nice,有木有? 下面两句也可以带 ...
- Python3基础 使用list() 生成一个空列表
镇场诗: 诚听如来语,顿舍世间名与利.愿做地藏徒,广演是经阎浮提. 愿尽吾所学,成就一良心博客.愿诸后来人,重现智慧清净体.-------------------------------------- ...
- mysql触发器的使用
环境情况: 表1:residential_building,住宅楼表:id,community(所属社区),countFloor(楼层数),countUnit(单元数),countHomesInUni ...
- Struts2--DomainModel接收参数---使用广泛!!!
1. JSP文件调用格式: <a href="user/user!add?user.name=a&user.age=8">添加用户</a> 2. s ...
- Windows下编译mxnet
操作系统: 64位Windows10 mxnet的构建和安装包括两个步骤: 第一步,编译出共享库 libmxnet.dll. 第二步,安装语言包,比如python等. 最小编译要求: 最新的支持C++ ...
- office加载项部署清单签名的证书或其位置不受信任
异常信息: System.Security.SecurityException: 此应用程序中的自定义功能将不起作用,原因是用于为 BIMT写作指导 的部署清单签名的证书或其位置不受信任.请向管理员寻 ...
- win10 下使用虚拟机安装ubuntu及其网络配置
通过虚拟机安装ubuntu 我的机器是64位的win10系统,使用的虚拟机VMware workstation 12 pro 安装的是ubuntu 14.04, 网上教程很多,很详细也有有效 win1 ...
- [算法] trie树实现
小写字母的字典树 #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAXN 1 ...