carloscn / carloscn/structstudy

leetcode1518:换水问题(water-bottles)

Open
#238 2 comments 0 reactions 1 assignee Claimed by @carloscn View on GitHub
Lang-rust Level-easy 一般问题 数学
Dominant language
C
Stars
4
Forks
1
PR merge metrics
No merged PRs in 30d

Description

### 问题描述

超市正在促销,你可以用 numExchange 个空水瓶从超市兑换一瓶水。最开始,你一共购入了 numBottles 瓶水。

如果喝掉了水瓶中的水,那么水瓶就会变成空的。

给你两个整数 numBottles 和 numExchange ,返回你 最多 可以喝到多少瓶水。

 

示例 1:

![image](https://github.com/carloscn/structstudy/assets/16836611/6f52d6b0-9188-43da-899e-0197717c1153)

输入:numBottles = 9, numExchange = 3
输出:13
解释:你可以用 3 个空瓶兑换 1 瓶水。
所以最多能喝到 9 + 3 + 1 = 13 瓶水。

示例 2:

![image](https://github.com/carloscn/structstudy/assets/16836611/a925177a-0efc-4145-b208-8d6872147db6)

输入:numBottles = 15, numExchange = 4
输出:19
解释:你可以用 4 个空瓶兑换 1 瓶水。
所以最多能喝到 15 + 3 + 1 = 19 瓶水。
 

 

提示:

1 <= numBottles <= 100
2 <= numExchange <= 100

来源:力扣(LeetCode)
链接:https://leetcode.cn/problems/water-bottles

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.