- 博客(4)
- 收藏
- 关注
原创 PAT 1068 Find More Coins python 非零返回问题 dfs+剪枝
题意:给若干硬币和要支付的价钱,返回最小的支付的结果,若没有支付方案则输出No Solution。题干不难理解,此题可以用dfs通过。其中测试点6是大规模数据,并且答案还是No Solution,所以先对所有硬币求和小于M直接输出。非零返回问题:错误代码:N, M = map(int, input().split())coins = sorted(list(map(int, input().split())))def dfs(i, total): if total ==
2022-04-24 15:52:31
2482
原创 1104 Sum of Number Segments python
Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we have 10 segments: (0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1, 0.2, 0.3, 0.4) (0.2) (0.2, 0.3) (0.2, ...
2022-04-22 22:51:44
1507
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人