当前位置:网站首页>7-17 crawling worms (break exercise)
7-17 crawling worms (break exercise)
2022-07-03 14:14:00 【Big fish】
A worm is long 1 " , In a deep for N The bottom of the well . Known worms every 1 Minutes to climb up U " , But must rest 1 Minutes to climb up . In the process of rest , The worm has slipped again D " . That's it , Go up and down again . Excuse me, , How long does it take for the worm to climb out of the well ?
There is not enough demand here 1 Minutes press 1 Minute meter , And assume that as long as the head of the worm reaches the top of the well during a climb , So the worm is done . At the beginning , Worms lie at the bottom of the well ( That is, the height is 0).
Input format :
The input is given in order on one line 3 A positive integer N、U、D, among D<U,N No more than 100.
Output format :
Output the time when the worm climbed out of the well in one line , In minutes .
Examples :"> sample input :
12 3 1
sample output :
11
Code :
#include<stdio.h>
int main()
{
int N,U,D,time=0,high=0;
scanf("%d%d%d",&N,&U,&D);
while(high<N)
{
high+=U;
time++;
if(high>=N)
break; // If the height has been reached or exceeded , No more rest . So jump out of the loop
high-=D;
time++;
}
printf("%d",time);
}
边栏推荐
- Sendmail无法发送邮件及发送过慢解决
- Common mixins
- Similarities and differences of sessionstorage, localstorage and cookies
- Exercise 10-8 recursive implementation of sequential output of integers
- 7-10 calculate salary
- JS continues to explore...
- MongoDB索引
- How to bold text in AI
- FPGA test method takes mentor tool as an example
- Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值
猜你喜欢
QT learning 20 standard dialog box in QT (middle)
Similarities and differences between Allegro, OrCAD, net alias, port, off page connector and how to select them
Example analysis of QT learning 18 login dialog box
Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值
Fabric. JS document
Solution to failure or slow downloading of electron when electron uses electron builder to package
Message subscription and publishing
JS matrix zero
28: Chapter 3: develop Passport Service: 11: define attributes in the configuration file, and then obtain them in the code;
愉悦资本新双币基金近40亿元完成首次关账
随机推荐
QT learning 24 layout manager (III)
好看、好用、强大的手写笔记软件综合评测:Notability、GoodNotes、MarginNote、随手写、Notes Writers、CollaNote、CollaNote、Prodrafts、Noteshelf、FlowUs、OneNote、苹果备忘录
fpga阻塞赋值和非阻塞赋值
必贝特医药冲刺科创板:年营收97万亏损1.37亿 拟募资20亿
Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)
Exercise 6-6 use a function to output an integer in reverse order
JVM object lifecycle
Leetcode(4)——寻找两个正序数组的中位数
虽然不一定最优秀,但一定是最努力的!
MIL-100( Fe) 包裹小分子阿司匹林形成[email protected](Fe)|甘草次酸修饰金属有机框架材料UiO-66-NH2(简称UiO-66-NH2-GA)
Understanding of closures
修改数据库中的记录为什么报这个错
Too many files with unapproved license
28:第三章:开发通行证服务:11:在配置文件中定义属性,然后在代码中去获取;
[ACNOI2022]猜数
TS code automatically generates JS
protobuf与grpc
JS shift operators (< <,> > and > > >)
QT learning 19 standard dialog box in QT (top)
超简单手机地图开发