题目大意:有一只蜗牛位于深一个深度为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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. UVA题目分类

    题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...

  5. Volume 1. Maths - Misc

    113 - Power of Cryptography import java.math.BigInteger; import java.util.Scanner; public class Main ...

  6. uva 1354 Mobile Computing ——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5

  7. UVA 10564 Paths through the Hourglass[DP 打印]

    UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...

  8. UVA 11404 Palindromic Subsequence[DP LCS 打印]

    UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...

  9. UVA&&POJ离散概率与数学期望入门练习[4]

    POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...

随机推荐

  1. Chapter 1 First Sight——19

    "I'm headed toward building four, I could show you the way…" Definitely over-helpful. &quo ...

  2. Chapter 1 First Sight——18

    But at least he sent me to an empty desk at the back without introducing me to the class. 但是最后他给我最后面 ...

  3. hdu_1007_Quoit Design(最近点对)

    题目连接:hdu_1007_Quoit Design 题意: 给你平面上的一些点,让你找出这些点的最近点对的距离 题解: 采用分治,达到O(nlognlogn)的时间复杂度就能艹过去了 #includ ...

  4. 解决adb端口被占用的方法

    错误: [2016-04-20 19:05:04 - ddms] 'E:\android\android-sdk\android-sdk\platform-tools\adb.exe,start-se ...

  5. 剑指offer 数字在排序数组中出现的次数

    因为有序 所以用二分法,分别找到第一个k和最后一个k的下标.时间O(logN) class Solution { public: int GetNumberOfK(vector<int> ...

  6. cakephp 的事件系统(Getting to grips with CakePHP’s events system), 基于观察者模式

    This article was written about CakePHP 2.x and has been untested with CakePHP 3.x CakePHP seems to g ...

  7. SUSE Linux Enterprise Server 11 SP1安装图解教程

    一.说明:操作系统:SUSE Linux Enterprise Server 11 SP1下载地址:需要注册才能下载二.安装系统 用启动盘成功引导之后,出现下面的界面 系统运维 温馨提醒:qihang ...

  8. 简单三段式状态机实验2-LCD12864

    此实验是在“基于I2C EPPRPM(AT24C02B) + LCD12864实验”基础上,把LCD模块里的一段式状态机改成三段式,I2C EPPROM模块暂时未改出来,一步一步来吧,改完后代码下载到 ...

  9. Firebug Console 与命令行全集

    Console API 当打开 firebug (也包括 Chrome 等浏览器的自带调试工具),window 下面会注册一个叫做 console 的对象,它提供多种方法向控制台输出信息,供开发人员调 ...

  10. column name is keyword from

    mysql: select tablename.from from tablename; postgresql: select "from" from tablename; sql ...