# Title Language Pasted on Will expire on Paste type
69 Go 2024-12-07 @ 07:50:08 UTC 2025-01-06 @ 07:50:08 UTC Public
View raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
func solvable2(res int, ins []int) bool {
        n, ins := ins[len(ins)-1], ins[:len(ins)-1]
        if len(ins) == 0 {
                return res == n
        }
        if solvable2(res-n, ins) {
                return true                                                                                                                                    
        }                                                                                                                                                      
        if res%n == 0 && solvable2(res/n, ins) {                                                                                                               
                return true                                                                                                                                    
        }                                                                                                                                                      
        d := digits(n)                                                                                                                                         
        p := pow10(d)                                                                                                                                          
        return res%p == n && solvable2(res/p, ins)                                                                                                             
}                                                                                                                                                              
                                                                                                                                                               
func digits(n int) int {                                                                                                                                       
        var d int = 1                                                                                                                                          
        for n > 10 {                                                                                                                                           
                d++                                                                                                                                            
                n /= 10                                                                                                                                        
        }                                                                                                                                                      
        return d                                                                                                                                               
}                                                                                                                                                              
                                                                                                                                                               
func pow10(n int) int {                                                                                                                                        
        var p int = 1                                                                                                                                          
        for ; n > 0; n-- {                                                                                                                                     
                p *= 10                                                                                                                                        
        }                                                                                                                                                      
        return p                                                                                                                                               
}