当前位置:网站首页>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 1Sample Output 1:
1 3 5Sample Input 2:
4 87 2 4 3Sample Output 2:
No Solution#include
边栏推荐
- 延迟加载js方式async与defer区别
- MySQL基础(一)---基础认知及操作
- C++ core programming
- App快速开发建设心得:小程序+自定义插件的重要性
- UVA10827
- 开发一套高容错分布式系统
- LAB Semaphore Implementation Details
- 【informix】解决启动报错大全,以及解决办法
- About the installation of sklearn library
- App rapid development and construction experience: the importance of small programs + custom plug-ins
猜你喜欢

请写出SparkSQL语句

逆向理论知识4

The production method of the powered small sailboat is simple, the production method of the electric small sailboat

How can Flutter parent and child components receive click events

【cesium】3D Tileset 模型加载并与模型树关联

What is ASEMI photovoltaic diode, the role of photovoltaic diode
虚证、实证如何鉴别?

App快速开发建设心得:小程序+自定义插件的重要性

There are a lot of 4T hard drives remaining, prompting "No space left on device" insufficient disk space

MySQL基础(一)---基础认知及操作
随机推荐
App rapid development and construction experience: the importance of small programs + custom plug-ins
Day14 jenkins deployment
UVA10827
作业8.4 进程间的通信 管道与信号
Develop your own node package
社区分享|腾讯海外游戏基于JumpServer构建游戏安全运营能力
How does the Flutter TapGestureRecognizer work
大学物理---质点运动学
密码学系列之:PEM和PKCS7,PKCS8,PKCS12
About the installation of sklearn library
AUTOCAD - dimension association
虚证、实证如何鉴别?
Excel Paint
C语言-大白话理解原码,反码和补码
结构光三维重建(二)线结构光三维重建
二叉树基本性质+oj题解析
特征预处理
AUTOCAD——标注关联
机器学习概述
In the hot summer, teach you to use Xiaomi smart home accessories + Raspberry Pi 4 to connect to Apple HomeKit