Problem A: Worm!!! -- 信息杯班级对抗赛
2014-12-13 12:59
148 查看
Problem A: Worm!!!
Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 165 Solved: 81
[Submit][Status][Web
Board]
Description
一个虫子在n单位长度的井下面,每分钟他可以走u单位长度,但是之后他要休息一分钟,并且在休息的时候他会下滑d单位长度,那么请你计算一下它需要多长时间爬出井?Input
输入包括n,u,d,并且d < u , n < 100.当n为0的时候输入结束Output
输出一个数代表虫子爬出井需要的时间。Sample Input
10 2 120 3 1
0 0 0
Sample Output
1719HINT
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <ctype.h> int main() { int n,u,d; int k = 0; while(scanf("%d%d%d",&n,&u,&d) != EOF) { k = 0; if(n == 0 &&u == 0 && d == 0) return 0; while(n > 0) { n = n - u; k++; if(n <= 0) //当已经爬出来时,就不会再掉下去了 break; n = n+d; k++; } printf("%d\n",k); } return 0; } /************************************************************** Problem: 1340 User: team47 Language: C Result: Accepted Time:0 ms Memory:748 kb ****************************************************************/
相关文章推荐
- Problem E: 点球大战 信息杯班级对抗赛
- Problem D: hardbird 的礼物 信息杯班级对抗赛
- Problem B: 怎么报数? 信息杯班级对抗赛
- Problem C: 龟兔赛跑之后 信息杯班级对抗赛
- ZOJ Problem Set – 1056 The Worm Turns
- ZOJ Problem Set - 1056 The Worm Turns
- HDOJ 4291 A Short problem(Fib矩阵相乘)
- POJ 2151--Check the difficulty of problem
- The C10K problem
- A Simple Math Problem
- 生成对抗网络GAN(一) 简介和变种
- hdu 4291 A Short problem
- poj 3468 A Simple Problem with Integers
- POJ 3320 Jessica's Reading Problem (原来标题在这里改……)
- Problem--71A--Codeforces--Way Too Long Words
- 《DEEP LEARNING AS A MIXED CONVEX COMBINATORIAL OPTIMIZATION PROBLEM》解读
- 杭电ACM第1000题(C语言版)答案——A + B Problem
- hdu2101 A + B Problem Too
- RAM-based Shift Register problem in Vivado 2014.4
- Python HTMLParser中有关转义字符的Problem&Solution