TLE '16 Contest 7 P4 - Abstract Problem
View as PDF        
            Submit solution
        
    
    
    
    
    
            
    
    
    
                    
                
        
        Points:
        
                10 (partial)        
    
    
        Time limit:
        1.0s
    
    
                Python 2
                6.0s
            
            
                Python 3
                6.0s
            
    
        Memory limit:
        256M
    
    
                        Author:
                        
                    
        
                    Problem type                
                
        
Abstract art, like abstract problems, is very enjoyable.
You see an abstract problem on Codeforces.
Given an integer  you want to change 
 into that number using a minimal number of the following operations:
- Add 
 - Subtract 
 - Multiply by 
 
You think it is too easy, so you increase  to 
 
, and decide that you should answer 
 
 of these queries per test case.
Input Specification
The first line of input will contain .
The next  lines of input will each contain 
.
Output Specification
For each , output on separate lines the minimal number of operations necessary to change 
 into 
.
Sample Input
2
32
15
Sample Output
6
6
Comments