leetcode每日一题 P3370 仅含置位位的最小整数 Created:2025-10-29 10:16:13Updated:2025-10-29 10:16:13algorithmalgorithm, leetcode每日一题, 位运算字数 94阅读 访客 时间轴 时间轴2025-10-29init 位运算 题目:P3370 仅含置位位的最小整数https://leetcode.cn/problems/smallest-number-with-all-set-bits/description/?envType=daily-question&envId=2025-10-29简单的位运算12345678910111213struct Solution;impl Solution { pub fn smallest_number(n: i32) -> i32 { let mut i = 1_i64; while i < n as i64 { i = (i << 1) | 1; } i as i32 }}fn main() { println!("Hello, world!");}