bzoj#P1531. [POI2005]Bank notes
[POI2005]Bank notes
题目描述
The Byteotian Bit Bank (BBB) has the largest network of cash dispensers in the whole Byteotia. The BBB have decided to improve their dispensers and have asked you for help. The legal tender in Byteotia are bank notes of denominations . The BBB have concluded that the cash dispensers are to pay every sum in the smallest possible total number of notes.
TaskWrite a programme that:
reads from the standard input the description of the dispenser's notes stock and the sum to be paid off,determines the minimal total number of bank notes sufficient to pay the desired sum off, and finds some way of paying it off as well (using the determined minimal number of notes, of course)writes the result to the standard output.
Byteotian Bit Bank (BBB)
拥有一套先进的货币系统,这个系统一共有 种面值的硬币,面值分别为 。但是每种硬币有数量限制,现在我们想要凑出面值 ,求最少要用多少个硬币.
输入格式
In the first line of the standard input the number of denominations is written , . The second line contains integers , , separated by single spaces. The third line contains integers , , also separated by single spaces; is the number of banknotes of denomination left in the cash dispenser. In the last, fourth line of input there is one integer - the sum to be paid off, . For the test data, you are free to assume that the sum can be paid off in the available banknotes.
第一行一个整数 。
第二行 个整数 ,表示这 种硬币的面值。
第三行 个整数 ,表示这 种硬币的数量。
第四行一个整数 。
输出格式
The first line of the standard output should contain one integer denoting the minimal total number of bank notes sufficient to pay the sum off . The second line should contain integers, separated by single spaces, denoting the numbers of notes of subsequent denominations used to pay off the sum . If there are many solutions your programme should write any of them.
第一行一个整数,表示最少需要多少个硬币。
第二行 个整数,表示第 种硬币需要多少个。
如果有多种方案,输出其中一种即可。
输入样例
3
2 3 5
2 2 1
10
输出样例
3
1 1 1
数据范围
对于 的数据,,,。