pprof是非常好用的性能分析工具
非 服 务 类 程 序 \red{非服务类程序} 非服务类程序
源代码:
package main
import (
"fmt"
"time"
)
func dfs(ans *[][]int,path []int,sum int,k int){
if sum > k {
return
}
if sum == k {
*ans = append(*ans, path)
return
}
for i:=1;i<10;i++{
t := i
path = append(path, t)
sum += t
dfs(ans, path, sum, k)
sum -= t
path = path[:len(path)-1:len(path)-1]
}
}
func solve(k int) [][]int{
ans := make([][]int,0)
path := make([]int,0)
dfs(&ans,path,0,k)
return ans
}
func main(){
start := time.Now()
fmt.Println(len(solve(24))