当前位置:网站首页>Zzuli:1072 frog climbing well
Zzuli:1072 frog climbing well
2022-06-28 05:27:00 【Don't explode】
Title Description
There is a mouth with a depth of high Meter well , There is a frog at the bottom of the well , It can climb up the well wall every day up rice , At night, it slides down the shaft wall down rice , If frogs start crawling out one morning , For any specified high、up and down value ( All are natural numbers ), Calculate how many days a frog can climb out of the wellhead ?
Input
Input 3 A positive integer :high、up and down.
Output
Output an integer , Days . The output is on a single line .
The sample input Copy
10 2 1
Sample output Copy
9
Tips
Loop simulation . Be careful , We can't simply think that the rising height every day is equal to the climbing distance during the day minus the falling distance at night , Because if you can climb out of the wellhead during the day , You don't have to wait until night .
#include <stdio.h>
int main()
{
int x=0,sum=0,day=1,high,up,down;
scanf("%d%d%d",&high,&up,&down);
while(1)
{
sum+=up;
if(sum>=high)
break;
sum-=down;
day++;
}
printf("%d",day);
return 0;
}边栏推荐
- Steve Jobs' speech at Stanford University -- follow your heart
- PCR/qPCR研究:Lumiprobe丨dsGreen 用于实时 PCR
- 【C语言练习——打印空心正方形及其变形】
- 【JVM系列】JVM调优
- Voltage mode and current mode control of switching power supply
- Concurrent wait/notify description
- Sorting out some topics of modern exchange principle MOOC
- Object detection with OpenCV
- Wedding studio portal applet based on wechat applet
- Extjs图书管理系统源码 智能化图书管理系统源码
猜你喜欢

Extjs library management system source code intelligent library management system source code

JS 文本框失去焦点修改全半角文字和符号

Share a powerful tool for factor Mining: genetic programming

【LeetCode】12、整数转罗马数字

MySQL export database dictionary to excel file

【Linux】——使用xshell在Linux上安装MySQL及实现Webapp的部署

mysql导出数据库字典成excel文件

Function reentry caused by Keil C51's data overlaying mechanism

metaRTC5.0编程之p2p网络穿透(stun)指南

Dart learning - functions, classes
随机推荐
Hundreds of lines of code to implement a script interpreter
Metartc5.0 API programming guide (I)
CpG solid support research: lumiprobe general CpG type II
关系数据库与文档数据库对比
CSCI GA scheduling design
It is the latest weapon to cross the blockade. It is one of the fastest ladders.
Lumiprobe cell imaging analysis: PKH26 cell membrane labeling kit
Steve Jobs' speech at Stanford University -- follow your heart
Dart learning - functions, classes
Create NFS based storageclass on kubernetes
The heading angle of sliceplane is the same as that of math Corresponding transformation relation of atan2 (y, x)
【JVM】——JVM中內存劃分
摄像头基础知识
How to do a good job of gateway high availability protection in the big promotion scenario
How does the power outlet transmit electricity? Simple problems that have plagued my little friend for so many years
Question bank and answers of 2022 materialman general basic (materialman) operation certificate examination
JS 文本框失去焦点修改全半角文字和符号
Unity delegate
Reactive dye research: lumiprobe af594 NHS ester, 5-isomer
Disable right-click, keyboard open console events