3100. 换水问题 II
This commit is contained in:
+9
-8
@@ -2,17 +2,18 @@ mod arr;
|
|||||||
struct Solution {}
|
struct Solution {}
|
||||||
|
|
||||||
impl Solution {
|
impl Solution {
|
||||||
pub fn triangular_sum(mut nums: Vec<i32>) -> i32 {
|
pub fn max_bottles_drunk(mut num_bottles: i32,mut num_exchange: i32) -> i32 {
|
||||||
for i in 0.. nums.len() - 1 {
|
let mut ans = num_bottles;
|
||||||
for j in 0..nums.len() - 1 - i {
|
while num_bottles >= num_exchange {
|
||||||
nums[j] = (nums[j] + nums[j + 1]) % 10;
|
num_bottles -= num_exchange;
|
||||||
}
|
ans += 1;
|
||||||
|
num_bottles += 1;
|
||||||
|
num_exchange += 1;
|
||||||
}
|
}
|
||||||
nums[0]
|
ans
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let arr = vec![1,2,3,4,5];
|
println!("{}", Solution::max_bottles_drunk(10,3));
|
||||||
println!("{}", Solution::triangular_sum(arr));
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user