UVA 573 The Snail
来源:互联网 发布:淘宝哪家iphone 编辑:程序博客网 时间:2024/06/04 23:40
题目
蜗牛
分析
- If the fatigue factor drops the snail’s climbing distance below
zero
, the snail does not climb at all that day. - In other words, the snail’s height will
exceed
the height of the well or become negative.
代码
#include <stdio.h>int test(int h, int u, int d, int f, int* day){ *day = 0; double ks = u, s = 0; while (++*day) { s += ks; if (s > h) return 1; s -= d; if (s < 0) return 0; ks -= f/100.0 * u; if (ks < 0) ks = 0; }}int main(void){ int h, u, d, f, day; while (scanf("%d%d%d%d", &h, &u, &d, &f), h) { printf(test(h, u, d, f, &day)? "success": "failure"); printf(" on day %d\n", day); } return 0;}
0 0
- UVa 573 - The Snail
- uva - 573 the snail
- uva 573 The Snail
- uva 573 - The Snail
- UVa 573 - The Snail
- UVa 573 - The Snail
- UVa 573 - The Snail
- UVA 573 The Snail
- uva 573 - The Snail
- uva 573 The Snail
- UVA 573 The Snail
- UVa 573 - The Snail
- Uva 573 The Snail
- UVA - 573 The Snail
- uva 573 The Snail
- UVA - 573 The Snail
- UVa:573 - The Snail
- uva 573 The Snail
- uva 10474 Where is the Marble?(简单题)
- 网络编程GUI:
- 愚人节的礼物
- 初识HTML
- Permutation Sequence
- UVA 573 The Snail
- 【第三次自考】第一阶段总结
- 基于递归的二叉树遍历
- 采药问题
- androd中主线程和非主线程的通信机制(Handler/Looper/Message)
- C++引用
- Vector
- eclipse完全支持jsp页面下HTML/JS/CSS智能提示
- 不使用第三个变量,交换两个变量的值