The K−P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the K−P factorization of N for any positive integers N, K and P. Input Specification: Each in
39. 组合总和 直接暴力思路,用dfs+回溯枚举所有可能组合情况.难点在于每个数可取无数次. 我的枚举思路是: 外层枚举答案数组的长度,即枚举解中的数字个数,从1个开始,到target/ min(candidates)终止. 然后内层就可以dfs搜索了, 缕清状态的转换与回溯,题就做出来了. dfs的状态函数:dfs(int k, int i, int[] candidates, List now, int nowCnt, int target, List<List> ans) k 代表当前