题目:

题解:
func combinationSum3(k int, n int) (ans [][]int) {
var temp []int
var dfs func(cur, rest int)
dfs = func(cur, rest int) {
// 找到一个答案
if len(temp) == k && rest == 0 {
ans = append(ans, append([]int(nil), temp...))
return
}
// 剪枝:跳过的数字过多,后面已经无法选到 k 个数字
if len(temp)+10-cur < k || rest < 0 {
return
}
// 跳过当前数字
dfs(cur+1, rest)
// 选当前数字
temp = append(temp, cur)
dfs(cur+1, rest-cur)
temp = temp[:len(temp)-1]
}
dfs(1, n)
return
}















![[激光原理与应用-98]:南京科耐激光-激光焊接-焊中检测-智能制程监测系统IPM介绍 - 2 - 什么是激光器焊接](https://img-blog.csdnimg.cn/direct/cb6a02565e544d97a705d3a6dd7ddcc9.png)
