1302 Snail
来源:互联网 发布:深圳it外包公司 编辑:程序博客网 时间:2024/04/30 18:12
水题,直接模拟就可解决。不过有几点需要注意:
1、如果刚好到达顶端,不算成功,他还会滑下来(坑爹呢。。。)
2、如果刚好到达底部,也还没结束,需要继续进行,知道攀爬高度为负数(也是坑。。。)
3、注意数据类型。
其他的没什么好说了~~
#include<iostream> #include<cstring> #include<sstream> #include<algorithm> #include<cstdio> #include<cmath> #include<string> #include<iomanip> using namespace std; const int MAX = 100100; int main() { double h,u,d,f,cur; while(cin>>h>>u>>d>>f && h) { double cur = 0; int day = 0; double dd = u*f*0.01; while(cur<h) { if(u>0) cur += u; if(cur>h) {day++; break;} cur -= d; if(cur<0) {day++; break;} if(u>0) u -= dd; day++; } if(cur<0) cout<<"failure on day "<<day<<endl; else cout<<"success on day "<<day<<endl; } return 0; }
0 0
- 1302 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
- HDU 1302 The Snail
- 1302 The Snail【模拟】
- hdu 1302 The Snail
- HDOJ 1302-The Snail
- HDU 1302 The Snail
- hdu 1302 The Snail
- HDOJ 1302 The Snail
- snail
- 杭电1302-The Snail
- Codeforces Round #292 (Div. 2)(A,B,C)
- Maven: 为Compiler插件设置source和target版本
- C++拾遗--定位new表达式
- Android数据的四种存储方式
- 用微信轻应用学习Axure7——第一讲:上翻页
- 1302 Snail
- Android中MenuInflater实例
- UTF-8 字节数,及首字节的对应关系
- 字符和字符串的基础知识
- Map数据类型使用new map()和null及clear方法后的不同之处
- vb6内联汇编,调用函数指针,不注册调用com
- C语言中关键字auto、static、register、const、volatile、extern的作用
- HDU 3746 Cyclic Nacklace(KMP找循环节)
- leetcode -- Largest Number