mirror of
				https://git.wolves.top/wolves/leetcode.git
				synced 2025-11-04 17:26:32 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			17 lines
		
	
	
		
			256 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			17 lines
		
	
	
		
			256 B
		
	
	
	
		
			C++
		
	
	
	
	
	
int leastMinutes(int n){
 | 
						|
    int i = 1;
 | 
						|
    int j = 1;
 | 
						|
    while(j < n){
 | 
						|
        j <<= 1;
 | 
						|
        i++;
 | 
						|
    }
 | 
						|
    return i;
 | 
						|
}
 | 
						|
 | 
						|
#include <cmath>
 | 
						|
 | 
						|
int leastMinutes(int n) {
 | 
						|
    if (n <= 0) return 0;
 | 
						|
    return static_cast<int>(std::ceil(std::log2(n))) + 1;
 | 
						|
}
 |