Climbing Worm

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10528    Accepted Submission(s): 6970

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 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
 
Source
 
 
 #include <stdio.h>

 int main()
{
int n,u,d;
while(scanf("%d %d %d",&n,&u,&d),n)
{
int t;
t=(n-u)/(u-d);
if(((n-u)%(u-d))!=)
t+=;
printf("%d\n",t*+);
}
return ;
}

简单题

 

hdu_1049_Climbing Worm_201311061331的更多相关文章

随机推荐

  1. thinkphp关联操作

    比如:你要求删除用户的时候,同时删除与用户有关的所有信息. 一对一:  有 (HAS_ONE)   属于 (BELONGS_TO)    一对多:  有 (HAS_MANY)  属于 (BELONG_ ...

  2. 什么是JavaScript的原始值?

    JavaScript的原始值是指数字.字符串.布尔值.null和undefined. JavaScript的数据类型分为两类:原始类型(primitive type)和对象类型(object type ...

  3. 爬虫—Ajax数据爬取

    一.什么是Ajax 有时候我们使用浏览器查看页面正常显示的数据与使用requests抓取页面得到的数据不一致,这是因为requests获取的是原始的HTML文档,而浏览器中的页面是经过JavaScri ...

  4. ORA-01075: you are currently logged on

    [root@hear01 ~]# su - oracle[oracle@hear01 ~]$ sqlplus "/as sysdba" SQL*Plus: Release 11.2 ...

  5. what is success?

    什么是成功?这是个老话题了.然而每个人对成功的认识却也不同.记得央视主持人王志说过成功是相对的,每个人都有自己的成功标准.有的人认为有钱.有房.有车.有女人,就是成功.有的人则认为成功是你做了一件你想 ...

  6. 使用UAParser在C#MVC项目中如何判断用户是在用什么设备进行访问(手机,平板还是普通的电脑)

    现在我们开发的很多web应用都要支持手机等移动设备.为了让手机用户能有更加好的用户体验,我们经常为手机设备专门准备一套前端的页面.这样当用户使用普通电脑来访问的时候,我们的应用就向用户展示普通电脑的页 ...

  7. layer实现在前台删除前确认弹出框,并回调后台删除事件

    最近遇到一些问题,用layer提示消息框,比如删除时,提示消息确定后 return false时,则不管用了,因为layer不支持阻塞,下面就解决一下这个问题:(本文使用Xcode,如要学习,请复下面 ...

  8. 初学者Android studio安装

    学习过java基础,最近趁着大量课余时间想学习Android开发.百度很多资料Android studio,由Google开发的开发工具,那就不需要再多说.对于初学者的我来说,一定足够用了.此文主要介 ...

  9. RTL Compiler之synthesis steps

    1 synthesis steps 1) Search Paths rc:/> set_attribute lib_search_path path / rc:/> set_attribu ...

  10. 显示log里的ansi codecs颜色字符

    方法: vim AnsiEsc插件 http://www.vim.org/scripts/script.php?script_id=302 less -r cat和tail命令都可以正常显示,而且ta ...