CDZSC_2015寒假新人(1)——基础 F

Description

An inch worm is at the bottom of a well n inches deep. It has enough energy to climb u inches every minute, but then has to rest a minute before climbing again. During the rest, it slips down d inches. The process of climbing and resting then repeats. How long before the worm climbs out of the well? We‘ll always count a portion of a minute as a whole minute and if the worm just reaches the top of the well at the end of its climbing, we‘ll assume the worm makes it out.

Input

There will be multiple problem instances. Each line will contain 3 positive integers n, u and d. These give the values mentioned in the paragraph above. Furthermore, you may assume d < u and n < 100. A value of n = 0 indicates end of output.

Output

Each input instance should generate a single integer on a line, indicating the number of minutes it takes for the worm to climb out of the well.

Sample Input

10 2 1

20 3 1

0 0 0

Sample Output

17

19

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
#ifdef CDZSC_OFFLINE
    freopen("in.txt","r",stdin);
#endif
    int n,u,d,sum,ans;
    while(scanf("%d%d%d",&n,&u,&d)&&n!=0&&u!=0&&d!=0)
    {
        sum=0,ans=0;
        while(sum+u<n)
        {
            sum+=u-d;
            ans+=2;
        }
        printf("%d\n",ans+1);
    }
    return 0;
}

时间: 2024-10-07 11:33:44

CDZSC_2015寒假新人(1)——基础 F的相关文章

CDZSC_2015寒假新人(1)——基础 E

Description Julius Caesar lived in a time of danger and intrigue. The hardest situation Caesar ever faced was keeping himself alive. In order for him to survive, he decided to create one of the first ciphers. This cipher was so incredibly sound, that

CDZSC_2015寒假新人(1)——基础 C

Description FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean.        The warehouse has N rooms. The i-th room contains J[i] pounds of JavaBeans and requires F[i] pounds

CDZSC_2015寒假新人(4)——搜索 F

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description Ignatius had a nightmare last night. He found himself in a labyrinth with a time bomb on him. The labyrinth has an exit, Ignatius should get out of the labyrinth

CDZSC_2015寒假新人(1)——基础 I

Description “Point, point, life of student!” This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can you get? Now, I told you the rules which are used in this course. There are 5 problems i

CDZSC_2015寒假新人(1)——基础 B

Description The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor

CDZSC_2015寒假新人(1)——基础 D

Description These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fairly difficulty to do such a thing. Of course, I got it after many waking nights.        Give you some integers, your task is to sort these number

CDZSC_2015寒假新人(1)——基础 G

Description Ignatius likes to write words in reverse way. Given a single line of text which is written by Ignatius, you should reverse all the words and then output them. Input The input contains several test cases. The first line of the input is a s

CDZSC_2015寒假新人(1)——基础 H

Description Ignatius was born in a leap year, so he want to know when he could hold his birthday party. Can you tell him?        Given a positive integers Y which indicate the start year, and a positive integer N, your task is to tell the Nth leap ye

CDZSC_2015寒假新人(2)——数学 - O

Description 当寒月还在读大一的时候,他在一本武林秘籍中(据后来考证,估计是计算机基础,狂汗-ing),发现了神奇的二进制数. 如果一个正整数m表示成二进制,它的位数为n(不包含前导0),寒月称它为一个n二进制数.所有的n二进制数中,1的总个数被称为n对应的月之数. 例如,3二进制数总共有4个,分别是4(100).5(101).6(110).7(111),他们中1的个数一共是1+2+2+3=8,所以3对应的月之数就是8. Input 给你一个整数T,表示输入数据的组数,接下来有T行,每