hdu1049

#include<stdio.h>

#include<iostream>

using namespace std;

int main()

{

int n,u,d;

int result;

int temp;

int i;

while(cin>>n&&n>0)

{

cin>>u>>d;

result=0;

temp=0;

temp=n-u;

int t=temp%(u-d);

if(t!=0)

{

temp=temp+u-d-t;

}

result=2*temp/(u-d)+1;

cout<<result<<endl;

}

return 0;

}

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-10-09 22:34:29

hdu1049的相关文章

HDU1049 Climbing Worm【水题】

题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1049 题目大意: 一直虫子掉在了一个长度为N米的井中,它每分钟向上爬u米,然后休息一分钟,休息期间会向下 掉d米,问:爬出井需要多久. 思路: 直接模拟即可.用time的奇偶来表示向上还是向下走. AC代码: #include<iostream> #include<algorithm> #include<cstdio> #include<cstring> us

HDU1049 Climbing Worm

Problem 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

HDU-1049

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