Buy the souvenirs
Time Limit: 10000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 927 Accepted Submission(s): 319
Problem Description When the winter holiday comes, a lot of people will have a trip. Generally, there are a lot of souvenirs to sell, and sometimes the travelers will buy some ones with pleasure. Not only can they give the souvenirs to their friends and families as gifts, but also can the souvenirs leave them good recollections. All in all, the prices of souvenirs are not very dear, and the souvenirs are also very lovable and interesting. But the money the people have is under the control. They can’t buy a lot, but only a few. So after they admire all the souvenirs, they decide to buy some ones, and they have many combinations to select, but there are no two ones with the same kind in any combination. Now there is a blank written by the names and prices of the souvenirs, as a top coder all around the world, you should calculate how many selections you have, and any selection owns the most kinds of different souvenirs. For instance:
And you have only 7 RMB, this time you can select any combination with 3 kinds of souvenirs at mZ??http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vc3QsIHNvIHRoZSBzZWxlY3Rpb25zIG9mIDMga2luZHMgb2Ygc291dmVuaXJzIGFyZSBBQkMgKDYpLCBBQkQgKDcpLiBCdXQgaWYgeW91IGhhdmUgOCBSTUIsIHRoZSBzZWxlY3Rpb25zIHdpdGggdGhlIG1vc3Qga2luZHMgb2Ygc291dmVuaXJzIGFyZSBBQkMgKDYpLCBBQkQgKDcpLAogQUNEICg4KSwgYW5kIGlmIHlvdSBoYXZlIDEwIFJNQiwgdGhlcmUgaXMgb25seSBvbmUgc2VsZWN0aW9uIHdpdGggdGhlIG1vc3Qga2luZHMgb2Ygc291dmVuaXJzIHRvIHlvdTogQUJDRCAoMTApLjxicj4KCiAKPHA+PGJyPgo8L3A+CklucHV0CkZvciB0aGUgZmlyc3QgbGluZSwgdGhlcmUgaXMgYSBUIG1lYW5zIHRoZSBudW1iZXIgY2FzZXMsIHRoZW4gVCBjYXNlcyBmb2xsb3cuPGJyPgpJbiBlYWNoIGNhc2UsIGluIHRoZSBmaXJzdCBsaW5lIHRoZXJlIGFyZSB0d28gaW50ZWdlciBuIGFuZCBtLCBuIGlzIHRoZSBudW1iZXIgb2YgdGhlIHNvdXZlbmlycyBhbmQgbSBpcyB0aGUgbW9uZXkgeW91IGhhdmUuIFRoZSBzZWNvbmQgbGluZSBjb250YWlucyBuIGludGVnZXJzOyBlYWNoIGludGVnZXIgZGVzY3JpYmVzIGEga2luZCBvZiBzb3V2ZW5pci4KPGJyPgpBbGwgdGhlIG51bWJlcnMgYW5kIHJlc3VsdHMgYXJlIGluIHRoZSByYW5nZSBvZiAzMi1zaWduZWQgaW50ZWdlciwgYW5kIDA8PW08PTUwMCwgMDxuPD0zMCwgdDw9NTAwLCBhbmQgdGhlIHByaWNlcyBhcmUgYWxsIHBvc2l0aXZlIGludGVnZXJzLiBUaGVyZSBpcyBhIGJsYW5rIGxpbmUgYmV0d2VlbiB0d28gY2FzZXMuCiAKPHA+PGJyPgo8L3A+Ck91dHB1dApJZiB5b3UgY2FuIGJ1eSBzb21lIHNvdXZlbmlycywgeW91IHNob3VsZCBwcmludCB0aGUgcmVzdWx0IHdpdGggdGhlIHNhbWUgZm9ybWF0aW9uIGFzIKGwWW91IGhhdmUgUyBzZWxlY3Rpb24ocykgdG8gYnV5IHdpdGggSyBraW5kKHMpIG9mIHNvdXZlbmlyc6GxLCB3aGVyZSB0aGUgSyBtZWFucyB0aGUgbW9zdCBraW5kcyBvZiBzb3V2ZW5pcnMgeW91IGNhbiBidXksIGFuZCBTIG1lYW5zIHRoZSBudW1iZXJzCiBvZiB0aGUgY29tYmluYXRpb25zIHlvdSBjYW4gYnV5IHdpdGggdGhlIEsga2luZHMgb2Ygc291dmVuaXJzIGNvbWJpbmF0aW9uLiBCdXQgc29tZXRpbWVzIHlvdSBjYW4gYnV5IG5vdGhpbmcsIHNvIHlvdSBtdXN0IHByaW50IHRoZSByZXN1bHQgobBTb3JyeSwgeW91IGNhbg=="t buy anything.”
Sample Input
2
4 7
1 2 3 4
4 0
1 2 3 4
Sample Output
You have 2 selection(s) to buy with 3 kind(s) of souvenirs.
Sorry, you can't buy anything.
Author wangye
Source HDU 2007-10 Programming Contest
Recommend 威士忌
题意:求最优方案数。
具体贴个别人的博客,我就是看这个学哒。
http://blog.csdn.net/wumuzi520/article/details/7019131
AC代码:
#include
#include
#include
#include
#include
#include
u