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. 利用AXIS2传递JSON数据

    Axis2是目前比较流行的WebService引擎.WebService被应用在很多不同的场景.例如,可以使用WebService来发布服务端 Java类的方法,以便使用不同的客户端进行调用.这样可以 ...

  2. Codeforces 803G Periodic RMQ Problem ST表+动态开节点线段树

    思路: (我也不知道这是不是正解) ST表预处理出来原数列的两点之间的min 再搞一个动态开节点线段树 节点记录ans 和标记 lazy=-1 当前节点的ans可用  lazy=0 没被覆盖过 els ...

  3. BZOJ DZY Loves Math系列

    ⑤(BZOJ 3560) $\Sigma_{i_1|a_1}\Sigma_{i_2|a_2}\Sigma_{i_3|a_3}\Sigma_{i_4|a_4}...\Sigma_{i_n|a_n}\ph ...

  4. [转]linux下logrotate 配置和理解

    转自:http://blog.csdn.net/cjwid/article/details/1690101 对于Linux 的系统安全来说,日志文件是极其重要的工具.系统管理员可以使用logrotat ...

  5. .net MVC成长记录(一)

    今天第一次写博客,之前从学校出来,学了ASP.NET, 现在第一份工作接触的是MVC,在此便记录和分享一下学习MVC的过程,希望能和大家多一些交流.言归正传,首先给大家介绍一下MVC的基础知识. MV ...

  6. SVN系列学习(二)-小乌龟的安装与配置

    1.TortoiseSVN的介绍 TortoiseSVN是Subversion版本控制系统的一个免费开源客户端,可以超越时间的管理文件和目录. 2.TortoiseSVN的安装 下载地址:http:/ ...

  7. C#学习-程序集和反射

    准备项目 1.新建一个空的解决方案MyProj.sln 2.在该解决方案下,建一个控制台项目P01.csproj 3.在该项目下,自己新建一个类MyFirstClass.cs 查看解决方案MyProj ...

  8. asp.net——登录界面

    题目: 在页面中放入两个TextBox分别用于输入用户名和密码,一个显示文字用的Label,一个提交按钮Button.点击按钮提交用户名和密码,如果用户名都密码正确(比如用户名admin 密码abc1 ...

  9. wordpress 你所不知道的固定链接设置方法,设置适合自己的个性固定链接,适合SEO

    %year% 年份,四位数字,例如2004年  %monthnum% 一年的月份,例如05  %day% 一个月的日子,例如28  %hour% 一天中的小时,例如15  %minute% 小时,例如 ...

  10. C#入门经典 Chapter3 变量和表达式

    3.1 C#基本语法 分号结束语句 花括号字符不需要附带分号 缩进     注释:/*....*/,//,/// 区分大小写 3.2 C#控制台应用程序的基本结构 namespace Chapter3 ...