当前位置:网站首页>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 :
11Code :
#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);
}边栏推荐
- Exercise 8-7 string sorting
- Reflection -- basic usage
- Duet date picker (time plug-in that can manually enter the date)
- Exercise 10-8 recursive implementation of sequential output of integers
- [combinatorics] permutation and combination (examples of combinatorial number of multiple sets | three counting models | selection problem | combinatorial problem of multiple sets | nonnegative intege
- Generate directories from web content
- protobuf与grpc
- Exercise 10-6 recursively find Fabonacci sequence
- Doxorubicin loaded on metal organic framework MIL-88 DOX | folic acid modified uio-66-nh2 doxorubicin loaded [email
- 金属有机骨架MIL-88负载阿霉素DOX|叶酸修饰UiO-66-NH2负载阿霉素[email protected]纳米粒子
猜你喜欢
随机推荐
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
消息订阅与发布
Redis:Redis的数据结构、key的操作命令
超简单手机地图开发
JVM runtime data area
天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
JS first summary
Strategy, tactics (and OKR)
Redis: commandes d'action pour les données de type chaîne
MongoDB索引
Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值
JS shift operators (< <,> > and > > >)
JS input number and standard digit number are compared. The problem of adding 0 to 0
[acnoi2022] guess numbers
Analysis of the characteristics of page owner
Leetcode(4)——尋找兩個正序數組的中比特數
JS download files through URL links
Scroll detection, so that the content in the lower right corner is not displayed at the top of the page, but is displayed as the mouse slides
Page generation QR code
愉悦资本新双币基金近40亿元完成首次关账








