Fast Bit Duplication
View as PDF        
            Submit solution
        
    
    
    
    
    
    
    
    
    
                    
                
        
            
        
        Points:
        
                10        
    
    
        Time limit:
        1.2s
    
    
        Memory limit:
        64M
    
    
                        Author:
                        
                    
        
                    Problem type                
                
        
                Allowed languages
            
            
C++            
        Given 32-bit unsigned integers, duplicate each bit in-place in the integer.
For example:
becomes
becomes
Implementation
One function:
unsigned long long duplicatebits(unsigned long long);
Note: The function parameter is an unsigned long long instead of an unsigned int to remove the step of upcasting.
Your function may be called up to  times.
Comments