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谁大的问 ...
随机推荐
- Chapter 1 First Sight——18
But at least he sent me to an empty desk at the back without introducing me to the class. 但是最后他给我最后面 ...
- C#入门经典(第三章-1)
#region--------#endregion 此关键字 将设置代码是否可以折叠和展开.但是他们不是C#关键字.注意:带#的是预处理指令,严格说不是C#关键字. 变量:
- js 获取n天前的时间
<script type="text/javascript"> var strdate = new Date(); var begindate = strdate.ge ...
- 安卓图表引擎AChartEngine(二) - 示例源码概述和分析
首先看一下示例中类之间的关系: 1. ChartDemo这个类是整个应用程序的入口,运行之后的效果显示一个list. 2. IDemoChart接口,这个接口定义了三个方法, getName()返回值 ...
- javascript 中的闭包
在 javascript 中,函数可以当做参数传递,也可以当做返回值返回. 当一个函数内部返回值为一个函数时, 就形成了闭包.(闭包里面的 this 问题) 如下面代码 Function.protot ...
- Persistent Bookcase
Persistent Bookcase time limit per test 2 seconds memory limit per test 512 megabytes input standard ...
- Unity3d之剥离alpha通道
unity中, 将图集的 alpha 通道剥离出来可减少包体大小和内存使用大小. 方法是将原来的一张 rgba 图分成一张 rgb 和一张 alpha 图,android上rgb和alpha图均采用e ...
- Oracle使用rowid删除重复记录
/**如何删除重复记录?*//*1. 先按重复字段分组 2. 在每组里找出最小的rowid 3. 把整个表中与上面查询出来的rowid不相等的记录删除掉*/delete from test_t ...
- 关于iOS自定义控件:在view上实现事件和代理
自定义控件.h #import <UIKit/UIKit.h> #import "PPViewtouchesBeginDelegate.h" @interface PP ...
- CodeForces 617C Watering Flowers
无脑暴力题,算出所有点到圆心p1的距离的平方,从小到大排序. 然后暴力枚举p1的半径的平方,计算剩余点中到p2的最大距离的平方,枚举过程中记录答案 #include<cstdio> #in ...