杭电 OJ 1302 The Snail
来源:互联网 发布:天盾安卓微信恢复软件 编辑:程序博客网 时间:2024/05/21 12:42
The Snail
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2954 Accepted Submission(s): 2129
Day| Initial Height| Distance Climbed |Height After Climbing |Height After Sliding
1 0 3 3 2
2 2 2.7 4.7 3.7
3 3.7 2.4 6.1 -
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.
6 3 1 1010 2 1 5050 5 3 1450 6 4 150 6 3 11 1 1 10 0 0 0
success on day 3failure on day 4failure on day 7failure on day 68success on day 20failure on day 2
#include <iostream>
using namespacestd;
int main()
{
double h,u,d,f;
while(cin>>h>>u>>d>>f&&h)//6总共需要爬行的高度 3//上升 1//下降 10 //10这一行代表疲劳百分比的分子
{
double s=u*f/100,sum=0;
int day=0;
int a=1;
while(1)
{
day++;
sum+=u;
if(sum>h) //根据题目所给例子可知,只有在蜗牛爬行总高度超过预定高度时,蜗牛才算爬出来
break;
sum-=d;
if(sum<0)
{
a=0;
break;
}
u-=s;
if(u<0) //太疲劳了,不能再上升了,肯定不能爬出去。
u=0;
}
if(a)
cout<<"success on day "<<day<<endl;
else
cout <<"failure on day "<<day<<endl;
}
return0;
}
- 杭电 OJ 1302 The Snail
- 杭电1302-The Snail
- 杭电1302 The Snail
- 杭电1302 The Snail
- 【杭电】[1302]The Snail
- The Snail(杭电 1302)
- 杭电 HDU ACM 1302 The Snail
- 杭电ACM-The Snail
- hdu-oj 1302 The Snail
- 杭电ACM1302——The Snail
- HDU 1302 The Snail
- hdu 1302 The Snail
- hdoj 1302 The Snail
- hdu 1302 The Snail
- hdu -1302 The Snail
- HDOJ The Snail 1302
- hdoj 1302 The Snail
- HDU 1302 The Snail
- js解析json的两种方法
- ng ui-route的toState, toParams, fromState, fromParams
- Caffeinated Logistic Regression of HDF5 Data
- 纪中集训d1 提高A组模拟
- Siamese network embedding 该例子是利用Caffe完成Siamese网络的特征抽取和plotting的例子。本文为了运行于本机,只做了细微修改和中文说明,原始文件来源于Ca
- 杭电 OJ 1302 The Snail
- 使用Qt编写opengl学习路线
- PLC梯形图编程基础知识详解
- POJ-3352 Road Construction(边双连通分量+缩点)
- java8之内存篇
- Js 获取客户区大小
- PreTranslateMessage无法捕获WM_VSCROLL 滑动条添加消息响应
- Java自增运算符和自减运算符,在变量前和变量后的区别。
- Java开发关键技术