2769. Find the Maximum Achievable Number Easy

@problem@discussion
#Math



1/**
2 * [2769] Find the Maximum Achievable Number
3 *
4 * Given two integers, num and t. A number x is achievable if it can become equal to num after applying the following operation at most t times:
5 * 
6 * 	Increase or decrease x by 1, and simultaneously increase or decrease num by 1.
7 * 
8 * Return the maximum possible value of x.
9 *  
10 * <strong class="example">Example 1:
11 * <div class="example-block">
12 * Input: <span class="example-io">num = 4, t = 1</span>
13 * Output: <span class="example-io">6</span>
14 * Explanation:
15 * Apply the following operation once to make the maximum achievable number equal to num:
16 * 
17 * 	Decrease the maximum achievable number by 1, and increase num by 1.
18 * </div>
19 * <strong class="example">Example 2:
20 * <div class="example-block">
21 * Input: <span class="example-io">num = 3, t = 2</span>
22 * Output: <span class="example-io">7</span>
23 * Explanation:
24 * Apply the following operation twice to make the maximum achievable number equal to num:
25 * 
26 * 	Decrease the maximum achievable number by 1, and increase num by 1.
27 * </div>
28 *  
29 * Constraints:
30 * 
31 * 	1 <= num, t <= 50
32 * 
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/find-the-maximum-achievable-number/
37// discuss: https://leetcode.com/problems/find-the-maximum-achievable-number/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42    pub fn the_maximum_achievable_x(num: i32, t: i32) -> i32 {
43        0
44    }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51    use super::*;
52
53    #[test]
54    fn test_2769() {
55    }
56}
57


Back
© 2025 bowen.ge All Rights Reserved.