mirror of
				https://git.wolves.top/wolves/leetcode.git
				synced 2025-11-04 17:26:32 +08:00 
			
		
		
		
	init
This commit is contained in:
		
							
								
								
									
										16
									
								
								greed/lcs01.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								greed/lcs01.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,16 @@
 | 
			
		||||
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;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user