hdu1302 The Snail
题目大意:
一只蜗牛在H英尺高的底部,想爬到顶端。蜗牛可以在太阳升起的时候爬上U英尺,但是在晚上睡觉的时候会滑下D英尺。蜗牛的疲劳系数为F(百分比), 这意味着蜗牛在每一天都比前一天少爬(F/100*U)英尺 【这个地方一直理解错了*(理解成了每天都比前一天少爬[F/100*(前一天爬的高度)])】。 问:蜗牛第几天离开井?
还有注意细节,定义数据类型是double,理解题意的顺序执行过程,不要把顺序搞错了。
#include<stdio.h>
int main()
{
int day;
double H,U,D,F;
double s,sum;
while(scanf("%lf%lf%lf%lf",&H,&U,&D,&F),H)
{
s=U;
sum=0;
day=0;
while(1)
{
day++;
if(s>0)
sum+=s;
if(sum>H) break;
sum = sum-D;
if(sum<0)
break;
s=s-F*U/100.0;
}
if(sum>H) printf("success on day %d\n",day);
else printf("failure on day %d\n",day);
}
return 0;
}
hdu1302 The Snail的更多相关文章
- 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 ...
- 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 ...
- Snail’s trouble
Snail’s trouble Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
- USACO 5.2 Snail Trails
Snail TrailsAll Ireland Contest Sally Snail likes to stroll on a N x N square grid (1 <n <= 12 ...
- Snail—OC学习之类别Category
类别就是向类加入一些实用的功能或者方法 利于开发 类能够是系统类.能够是自己定义类 类别跟子类是不一样的.类别仅仅能加入一些方法 属性变量什么的不能够加入 不创建新类,就可以对已有类进行扩展 做项目的 ...
- [USACO5.2]蜗牛的旅行Snail Trails(有条件的dfs)
题目描述 萨丽·斯内尔(Sally Snail,蜗牛)喜欢在N x N 的棋盘上闲逛(1 < n <= 120). 她总是从棋盘的左上角出发.棋盘上有空的格子(用“.”来表示)和B 个路障 ...
- Snail—UI学习之UITextField
简单看一下UITextField的属性 - (void)createTextField{ UITextField * textField = [[UITextField alloc] initWith ...
- 洛谷——P1560 [USACO5.2]蜗牛的旅行Snail Trails
P1560 [USACO5.2]蜗牛的旅行Snail Trails 题目描述 萨丽·斯内尔(Sally Snail,蜗牛)喜欢在N x N 的棋盘上闲逛(1 < n <= 120). 她总 ...
- 洛谷 P1560 [USACO5.2]蜗牛的旅行Snail Trails(不明原因的scanf错误)
P1560 [USACO5.2]蜗牛的旅行Snail Trails 题目描述 萨丽·斯内尔(Sally Snail,蜗牛)喜欢在N x N 的棋盘上闲逛(1 < n <= 120). 她总 ...
随机推荐
- delphi实现两个目录路径的链接
filepath := PathJoin(['C:', 'path1', 'path2\', 'a.doc']); // filepath = 'C:\path1\path2\a.doc' 代码: f ...
- substring_index 用法
substring_index http://blog.csdn.net/wolinxuebin/article/details/7845917 1.substring_index(str,delim ...
- Python合并列表,append()、extend()、+、+=
在实际应用中涉及到了列表合并的问题. 在应用append()时,发现列表是以一个元素的形式追加到列表上的,最后查询后用的是extend()方法,下面是区别 1.append() 向列表尾部追加一 ...
- 兼容IE7、IE8、IE9的input type="number"插件
IE11版本好像才兼容input type="number",但是现在Win7版本操作系统下,很多人的IE版本都是IE7/8/9,所以为了体验就自己写了一个小插件,支持设置最大值. ...
- oracle中的分支与循环语句
分支语句 if的三种写法一, if 2 < 1 then dbms_output.put_line('条件成立'); end if; 二, if 2 < 1 then dbms_outpu ...
- [SCOI2007]修车(建图好题)
[SCOI2007]修车 https://www.lydsy.com/JudgeOnline/problem.php?id=1070 Time Limit: 1 Sec Memory Limit: ...
- 旋转链表(所有元素往右移) rotate list
[抄题]: 给定一个链表,旋转链表,使得每个节点向右移动k个位置,其中k是一个非负数 样例 给出链表1->2->3->4->5->null和k=2 返回4->5-& ...
- [leetcode]318. Maximum Product of Word Lengths单词长度最大乘积
Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the tw ...
- Loitor_产品(二)校准立体摄像机
[1]Loitor VI Sensor 可以通过 ROS 自自带的双目相机标定工工具 cameracalibrator.py 来标定相机内参,详细过程http://wiki.ros.org/camer ...
- Struts2的拦截器技术
1. 拦截器的概述 * 拦截器就是AOP(Aspect-Oriented Programming,面向切面)的一种实现.(AOP是指用于在某个方法或字段被访问之前,进行拦截然后在之前或之后加入某些操作 ...