题解:CF687C The Values You Can Make】的更多相关文章

C. The Values You Can Make time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Pari wants to buy an expensive chocolate from Arya. She has n coins, the value of the i-th coin is ci. The price…
题意:给定n个硬币,每个硬币都有面值,求每个能构成和为k的硬币组合中,任意个数相互求和的总额种类,然后将所有硬币组合中最后得到的结果输出. 解题关键:在01背包的过程中进行dp.dp[i][j]表示组成i的总额时,是否可以组成j的额度. 假如枚举到的硬币面值为t ,如果存在dp[i-t][j]=true,那么有 1.dp[i][j]=true;  相当于总额里增加一个t的面值的硬币,但实际组成j的额度时并没有用到它. 2.dp[i][j+t]=true;;  相当于总额里增加一个t的面值的硬币,…
贪心基础 贪心(Greedy)常用于解决最优问题,以期通过某种策略获得一系列局部最优解.从而求得整体最优解. 贪心从局部最优角度考虑,只适用于具备无后效性的问题,即某个状态以前的过程不影响以后的状态.紧接下来的状态仅与当前状态有关.和分治.动态规划一样,贪心是一种思路,不是解决某类问题的具体方法. 应用贪心的关键,是甄别问题是否具备无后效性.找到获得局部最优的策略.有的问题比较浅显,例如一道找零钱的题目 LeetCode 860. Lemonade Change: // 860. Lemonad…
/*MySQL - 5.5.47 *************//*!40101 SET NAMES utf8 */; create table `base_area` (    `codeid` mediumint (12),    `parentid` int (12),    `cityName` varchar (180)); insert into `base_area` (`codeid`, `parentid`, `cityName`) values('11','0','北京');i…
采集了一下JD的省市区地区 (非常简单,只是做个记录) 1.建表:account_area   2.进入页面: https://reg.jd.com/reg/company 在浏览器(Firefox)控制台(Firebug)上输入:(其他浏览器的控制台也行) var $cr=$(".copyright"); $cr .empty(); function getAreas3(id){ $.get("https://reg.jd.com/reg/area", { lev…
思路: 如果用朴素的方法算O(n^4)超时,这里用折半二分.把数组分成两块,分别计算前后两个的和,然后枚举第一个再二分查找第二个中是否有满足和为0的数. 注意和有重复 #include<iostream> #include<algorithm> #include<cstring> #define ll long long using namespace std; const int N = 4000+5; int a[N],b[N],c[N],d[N]; int mp1…
题意:长为n的串,给你m个区间,这些区间内元素不重复,问这样的串字典序最小为? 思路:用set保存当前能插入的元素,这样就能直接插入最小元素了.对操作按l排序,因为排过的不用排,所以两个指针L,R是一直右移的.L右移肯定是增加set中元素,R右移有两种可能:一是L在R右边,R只是负责赶路赶到操作区间:二是L在R左边,那么R右移是在扩大区间,并且对数组中元素进行插入. 代码: #include<cstdio> #include<vector> #include<set>…
传送门 4 Values whose Sum is 0 Time Limit: 15000MS   Memory Limit: 228000K Total Submissions: 20334   Accepted: 6100 Case Time Limit: 5000MS Description The SUM problem can be formulated as follows: given four lists A, B, C, D of integer values, compute…
POJ 2823 Sliding  Window 题解 Description An array of size n ≤ 106 is given to you. There is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the slidi…
http://vjudge.net/problem/viewProblem.action?id=37480 East Central Regional Contest Problem C: Hexagon Perplexagon A well known puzzle consists of hexagonal pieces, each with the numbers through printed on the sides. Each piece has a different arrang…