当前位置:网站首页>1068找到更多的硬币
1068找到更多的硬币
2022-08-05 05:05:00 【Brosto_Cloud】
Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However, there was a special requirement of the payment:for each bill, she must pay the exact amount. Since she has as many as 104 coins with her, she definitely needs your help. You are supposed to tell her, for any given amount of money, whether or not she can find some coinsto pay for it.
Input Specification:
Each input file contains one test case. For each case, the first line contains 2 positive numbers: N
(≤104, the total number of coins) and M
(≤102, the amount of money Eva has to pay). The second line contains N
face values of the coins, which are all positive numbers. All the numbers in a line are separated by a space.
Output Specification:
For each test case, print in one line the face values V1≤V2≤⋯≤Vk such that V1+V2+⋯+Vk=M
. All the numbersmust be separated by a space, and there must be no extra space at the end of the line. If such a solution is not unique, output the smallest sequence. If there is no solution, output "No Solution" instead.
Note: sequence {A[1], A[2], ...} is said to be "smaller" than sequence {B[1], B[2], ...} if there exists k≥1 such that A[i]=B[i] for all i In the beginning, using dfs+pruning, the test point 6 timed out, and it is fine to judge that the sum of all coins is less than m:Sample Input 1:
8 95 9 8 7 2 3 4 1
Sample Output 1:
1 3 5
Sample Input 2:
4 87 2 4 3
Sample Output 2:
No Solution
#include
边栏推荐
- Flutter学习4-基本UI组件
- Develop a highly fault-tolerant distributed system
- entry point injection
- u-boot调试定位手段
- There are a lot of 4T hard drives remaining, prompting "No space left on device" insufficient disk space
- How to quickly upgrade your Taobao account to a higher level
- 重新审视分布式系统:永远不会有完美的一致性方案……
- dedecms后台生成提示读取频道信息失败的解决方法
- human weakness
- Analyses the mainstream across technology solutions
猜你喜欢
WPF中DataContext作用
creo怎么测量点到面的距离
JeeSite New Report
Error creating bean with name ‘configDataContextRefresher‘ defined in class path resource
【cesium】加载并定位 3D Tileset
Dephi reverse tool Dede exports function name MAP and imports it into IDA
Flutter real machine running and simulator running
About the installation of sklearn library
ansible各个模块详解
Day019 Method overriding and introduction of related classes
随机推荐
flex布局青蛙游戏通关攻略
Qt制作18帧丘比特表白意中人、是你的丘比特嘛!!!
Flutter TapGestureRecognizer 如何工作
虚证、实证如何鉴别?
Talk about 20 common problems in data governance
数字孪生技术在电力系统中的应用现状
How to identify false evidence and evidence?
【软考 系统架构设计师】软件架构设计③ 特定领域软件架构(DSSA)
Flutter real machine running and simulator running
The role of DataContext in WPF
Develop a highly fault-tolerant distributed system
How can Flutter parent and child components receive click events
Why did you start preparing for the soft exam just after the PMP exam?
[cesium] 3D Tileset model is loaded and associated with the model tree
Flutter learning 2-dart learning
mutillidae download and installation
number_gets the specified number of decimals
Flutter学习4-基本UI组件
The production method of the powered small sailboat is simple, the production method of the electric small sailboat
动力小帆船制作方法简单,电动小帆船制作方法