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. 数据库异常 :java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

    最近在新项目中突然出现了  java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) ...

  2. Java经典算法之选择排序(Select Sort)

    思路:就是把所有数据项扫描一遍,挑出最小的那个和最左边的交换位置,即放到0位置.现在最左边的就是有序得了,不需要在交换位置,再次扫描数据时就是从1开始,还是寻找最小的和1交换位置,直到所有数据都是有序 ...

  3. mina2 笔记

    http://www.iteye.com/topic/1112123 http://dongxuan.iteye.com/blog/901689 http://scholers.iteye.com/b ...

  4. [转]android 获取 imei号码

    核心代码: Imei = ((TelephonyManager) getSystemService(TELEPHONY_SERVICE)) .getDeviceId(); 1.加入权限 在manife ...

  5. ios的认识

    刚进了ios兴趣班,第一次使用苹果电脑,因为苹果电脑和windows电脑使用的区别很大.所以老师教我们苹果电脑的基本使用,以及关于苹果产品的一些认识.我听得热血沸腾,对苹果开发越来越感兴趣,相信下次上 ...

  6. JVM 内存分配和垃圾回收(GC)机制

    一  判断对象是否存活 垃圾收集器在对堆进行回收前,第一件事情就是要确定这些对象之中哪些还“活着”,哪些已经"死去”,即不能再被任何途径使用的对象. 1.1 引用计数法 (Reference ...

  7. MySQL索引----数据结构及算法原理

    摘要 本文以MySQL数据库为研究对象,讨论与数据库索引相关的一些话题.特别需要说明的是,MySQL支持诸多存储引擎,而各种存储引擎对索引的支持也各不相同,因此MySQL数据库支持多种索引类型,如BT ...

  8. CSS——规避脱标流和vertical-align

    规避脱标流: 1.尽量使用标准流. 2.标准流解决不了的使用浮动. 3.浮动解决不了的使用定位. 问题解决:嵌套盒子在不使用定位的情况下定位到右上角 <!DOCTYPE html> < ...

  9. MVC5+EasyUI+EF6+Linq通用权限系统出炉(1)

    1.先晒一下结构吧,

  10. 在CentOS6,CentOS7安装 Let'sEncrypt 免费SSL安全证书

    相对来说,个人网站建立SSL是昂贵的,而且往往过程繁琐.一个标准的2048位证书费用至少150美元/年,网站除了要支付一笔昂贵的费用.重新配置Web服务器,并需要解决大量的配置错误.这让广大中小网站望 ...