题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1235 题意: 有N个硬币(N<=18).问是否能在每一个硬币使用不超过两次的情况下支付正好K的面额. 思路 : dfs构造出用这些硬币用前一半能支付的全部费用和后一半能支付的全部费用. 之后排序,枚举前一半的每一个面值在第二个里面二分寻找就可以.(或者用set保存). 代码:(set) #include <stdio.h> #include <ctime>…
题目链接: http://www.lightoj.com/volume_showproblem.php?problem=1235 题目描述: 给出n个硬币,每种硬币最多使用两次,问能否组成K面值? 解题思路: 因为K草鸡大,尽管n很小,但是2^n很大,无法用背包做到O(nK)的复杂度.如果暴力枚举复杂度立马飙升到O(2^(n+1)).··········· 所以引进一种新的算法,折半查找:把所要枚举的值,先把前部分的值所有情况枚举出来,再把后部分的值所有情况枚举出来并排序,结合二分进行查找. 这…
1235 - Coin Change (IV)    PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB Given n coins, values of them are A1, A2 ... An respectively, you have to find whether you can pay K using the coins. You can use any coin at most t…
Coin Change (IV) Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu [Submit]   [Go Back]   [Status] Description Given n coins, values of them are A1, A2 ... An respectively, you have to find whether you can pay K using the coin…
题目链接: Lightoj  1231 - Coin Change (I) 题目描述: 就是有n种硬币,每种硬币有两个属性(价值,数目).问用给定的硬币组成K面值,有多少种方案? 解题思路: 赤果果的多重背包,简单搞一下就好了.席八!烦烦烦.今天绝对是出门刷提前没看黄历,刚开始套了一个多重背包板子,蓝而跑出来的答案并不对,改来改去就错在细节的地方. #include <cmath> #include <cstdio> #include <cstring> #includ…
先上题目: 1232 - Coin Change (II)   PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB In a strange shop there are n types of coins of value A1, A2 ... An. You have to find the number of ways you can make K using the coins. You ca…
先上题目: 1231 - Coin Change (I)   PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB In a strange shop there are n types of coins of value A1, A2 ... An. C1, C2, ... Cn denote the number of coins of value A1, A2 ... An respective…
C - Coin Change (III) Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice LightOJ 1233 Description In a strange shop there are n types of coins of value A1, A2 ... An. C1, C2, ... Cn denote the number of…
You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins,…
Coin Change Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10289    Accepted Submission(s): 3451 Problem Description Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1…