UVa 573 The Snail (模拟)

573 - The Snail

Time limit: 3.000 seconds

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=99&page=show_problem&problem=514

A snail is at the bottom of a 6-foot well and wants to climb to the top. The snail can climb 3 feet while the sun is up, but slides down 1 foot at night while sleeping. The snail has a fatigue factor of 10%, which means that on each successive day the snail climbs 10% 3 = 0.3 feet less than it did the previous day. (The distance lost to fatigue is always 10% of the first day's climbing distance.) On what day does the snail leave the well, i.e., what is the first day during which the snail's height exceeds 6 feet? (A day consists of a period of sunlight followed by a period of darkness.) As you can see from the following table, the snail leaves the well during the third day.

Your job is to solve this problem in general. Depending on the parameters of the problem, the snail will eventually either leave the well or slide back to the bottom of the well. (In other words, the snail's height will exceed the height of the well or become negative.) You must find out which happens first and on what day.

Input

The input file contains one or more test cases, each on a line by itself. Each line contains four integersH, U, D, and F, separated by a single space. If H = 0 it signals the end of the input; otherwise, all four numbers will be between 1 and 100, inclusive. H is the height of the well in feet, U is the distance in feet that the snail can climb during the day, D is the distance in feet that the snail slides down during the night, and F is the fatigue factor expressed as a percentage. The snail never climbs a negative distance. If the fatigue factor drops the snail's climbing distance below zero, the snail does not climb at all that day. Regardless of how far the snail climbed, it always slides D feet at night.

Output

For each test case, output a line indicating whether the snail succeeded (left the well) or failed (slid back to the bottom) and on what day. Format the output exactly as shown in the example.

时间: 2024-10-15 00:56:30

UVa 573 The Snail (模拟)的相关文章

UVa 11210 Chinese Mahjong :模拟&枚举&回溯

11210 - Chinese Mahjong Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=2151 Mahjong () is a game of Chinese origin usually played by four persons with tiles resembling dominoes and beari

UVa 253 Cube painting (模拟)

253 - Cube painting Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=99&page=show_problem&problem=189 We have a machine for painting cubes. It is supplied with three different colors:

uva 188 - Perfect Hash 模拟

       这题只要读懂题就等于没难度了,完全照着题目给的公式模拟即可      要注意的就是末尾的多余空格.   /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #include <iostream> #include <cstdio> #include <cstdlib> #inc

uva 1330 - City Game 模拟

    扫描线,记录l,r,u,答案就是(r+l-1)*u     实际上只要开个2维数组就可以了 /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #include <iostream> #include <cstdio> #include <cstdlib> #include <

uva 11549 - Calculator Conundrum 模拟

      Floyd判圈算法,好厉害的样子       用sscanf要2s,速度太低,不过比较好写,要注意是字符数组要开19以上  /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #include <iostream> #include <cstdio> #include <cstdlib

uva 11995 I Can Guess the Data Structure!

点击打开链接uva 11995 思路: STL模拟 分析: 1 分别用三种STL去模拟这些操作,然后进行判断输出 2 比较简单 代码: #include<stack> #include<queue> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; stack<int> stk; qu

uva 12096 The SetStack Computer

点击打开链接uva 12096 思路: STL模拟 分析: 1 题目给定5种操作,每次输出栈顶集合的元素的个数 2 利用stack和set来模拟,set保存集合的元素.遇到push的时候直接在stack里面push入一个空的set,遇到Dup的时候把栈顶的集合在push进stack一次,遇到union的时候把栈顶的两个集合合并,遇到Intersect的时候把栈顶的两个集合进行求交集然后push进stack,遇到Add的时候要注意如果第一个集合是空集那么我们就认为是在第二个集合里面加入2,否则就要

uva 11210 Chinese Mahjong

点击打开链接uva 11210 思路:模拟 分析: 1 根据题目我们可以知道总共有34种牌,分别是(9张饼+9张条+9张万+东南西北+中发白) 2 题目明确说明"胡牌"的请况是"将+刻子(>=0)+顺子(>=0)",那么我们知道最多有34总牌,那么我们只要去枚举每一种是否可以作为将,然后去判断剩下的是否满足刻子和顺子即可 3 注意题目明确说明如果输入的时候是4张一样的牌,那么这个牌是不可能听的. 代码: #include<cstdio> #i

uva 11549 - Calculator Conundrum

点击打开链接uva 11549 思路:模拟 分析: 1 题目要求找到最大的n位数,那么我们通过不断的模拟,求出最大的ans 2 这里有个问题就是我们怎么知道什么时候结束呢?我们知道如果当前数已经有出现了那么说明刚好一个循环,这里利用map映射 代码: #include<map> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using names