CodeForces 688E-The Values You Can Make】的更多相关文章

题目链接: E. 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…
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 of the chocolate is k, so P…
题目链接:http://codeforces.com/problemset/problem/687/C 题目大概说给n个各有价值的硬币,要从它们中选出若干个组合成面值k,而要求的是各个方案里这些选出的硬币能组合出来的面值有哪些. dp[i][j][k]表示到第i个硬币,组成面值为j,包含面值为k的方案数. 注意用滚动数组写. //#pragma comment(linker, "/STACK:102400000, 102400000") #include <algorithm&g…
题目大概说给n个各有价值的硬币,要从它们中选出若干个组合成面值k,而要求的是各个方案里这些选出的硬币能组合出来的面值有哪些. 有点绕.. dp[i][j][k]表示前i个硬币中 能否 组合成面值j且选出的硬币能组合成面值k 转移要考虑全面..三个方向转移,第i个不选.第i个选但不参与选出硬币去组合成k.第i个选且参与选出硬币去组成成k #include<cstdio> using namespace std; ][][]; int main(){ int n,K,a; scanf("…
题意:一个数组a[i],你可以挑出若干个数(只能挑一次)加起来等于k, 针对每一种方案,你可以选出这若干个数的子集来组合新数 最后所有的方案能组合出多少种数 分析:一看数据范围n,k<=500 那就是显而易见就是母函数那套了 从1到n,dp[i][j],代表通过前i个元素和为i,能否组合出j #include <cstdio> #include <iostream> #include <ctime> #include <vector> #include…
$dp$,背包. $f[i][j][s]$表示前$i$个物品,凑出$j$价格的情况下,能否凑出$s$价格,$f[i][j][s]=1$表示能,否则不能. 转移很简单:如果$f[i][j][s]=1$,那么$f[i+1][j][s]=1$,$f[i+1][j+c[i]][s]=1$,$f[i+1][j+c[i]][s+c[i]]=1$.最后将$f[n][k][s]=1$的$s$都输出就可以了. $f[500][500][500]$内存会炸,第一维可以用滚动数组优化. #pragma comment…
这个也可以说是一个01背包了,里面也有一些集合的思想在里面,首先dp方程,dp[i][j]代表着当前数值为i,j能否被构成,如果dp[i][j] = 1,那么dp[i+m][j] 和 dp[i+m][j+m] = 1,所以转移方程就写出来了,但是注意我们只能从后向前转移,也就是说我们一定要用选上一个数的状态,因为这里是01背包,每一个数只能选一次,如果正着选就是完全背包了. 代码如下: #include<iostream> #include<cstdio> #include<…
Problem_A(CodeForces 688A): 题意: 有d天, n个人.如果这n个人同时出现, 那么你就赢不了他们所有的人, 除此之外, 你可以赢他们所有到场的人. 到场人数为0也算赢. 现给出这n个人d天的到勤情况, 求最大连胜天数. 思路: 暴力找下去, 维护最大天数即可. 代码: #include <cmath> #include <cstdio> #include <cstring> #include <cstdlib> #include…
/*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…
E - The Values You Can Make Description Pari wants to buy an expensive chocolate from Arya. She has n coins, the value of the i-th coin is ci. The price of the chocolate is k, so Pari will take a subset of her coins with sum equal to k and give it to…
E. The Values You Can Make     Pari wants to buy an expensive chocolate from Arya. She has n coins, the value of the i-th coin is ci. The price of the chocolate is k, so Pari will take a subset of her coins with sum equal to k and give it to Arya. Lo…
题目链接: 题目 E. The Values You Can Make time limit per test:2 seconds memory limit per test:256 megabytes 问题描述 Pari wants to buy an expensive chocolate from Arya. She has n coins, the value of the i-th coin is ci. The price of the chocolate is k, so Pari…
题目链接:http://codeforces.com/contest/688/problem/E 题解:设dp[s1][s2]表示s1状态下出现s2是否合理.那么s1显然可以更具01背包来得到状态.首先看一下转移方程 if(dp[i-a[k]][j]) => (1)dp[i][j]=dp[i-a[k]][j], (2)dp[i][j+a[k]]=dp[i-a[k]][j] 解释(1),(2) 怎么得到的:当i-a[k]的状态存在那么显然可以推到i这个状态,那么j这个状态要么加上a[k]要么不加a…
题意: 给出n,k,分别代表硬币的数量与巧克力的价格,n个整数c1,c2,...ci...cn(ci代表第i块硬币的值);你可以从n块硬币中拿出金额恰好为k的硬币数并将其中的任意两块硬币组合得到一个数,将其保存下来(0和输入的n个数的值也必须被保存),最后将这些数按升序排列输出. 分析: 可以采用dp的递推方法,从1到n,dp[i][j]代表通过前i个元素和为i,能否组合出j. 代码如下: #include <cstdio> #include <iostream> #include…
Codeforces#262_1002 B. Little Dima and Equation time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him…
前面说点什么.. 为了完成日常积累,傻逼呵呵的我决定来一发codeforces 挑水题 泛做.. 嗯对,就是泛做.. 主要就是把codeforces Div.1的ABCD都尝试一下吧0.0.. 挖坑0.0.. Codeforces Round #360 A. NP-Hard Problem 就是一个二分图染色,判断是否为二分图而已.. B. Remainders Game 题意:有一个未知的\(x\)和已知\(x\ mod\ c_i\)的值,问是否能确定\(x\ mod\ k\)的值 考虑一下中…
1.前言 虽然这次我依旧没有参加正式比赛,但是事后还是看了看题目的...一般不怎么刷Codeforces. A.Raising Bacteria You are a lover of bacteria. You want to raise some bacteria in a box. Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night…
C. Polycarp at the Radio time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented a…
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=102271#problem/B Description Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500,…
Description An array of positive integers a1, a2, ..., an is given. Let us consider its arbitrary subarray al, al + 1..., ar, where 1 ≤ l ≤ r ≤ n. For every positive integer s denote by Ks the number of occurrences of s into the subarray. We call the…
Megacity Time Limit: 2000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description The administration of the Tomsk Region firmly believes that it's time to become a megacity (that is, get population of one million). Inste…
Guess a number! Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description A TV show called "Guess a number!" is gathering popularity. The whole Berland, the old and the young, are watching the sho…
Unusual Product Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description Little Chris is a huge fan of linear algebra. This time he has been given a homework about the unusual square of a square matrix. T…
A. Currency System in Geraldion Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/560/problem/A Description A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But th…
A. Lineland MailTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/problem/A Description All cities of Lineland are located on the Ox coordinate axis. Thus, each city is associated with its position xi — a coordinate on the…
G. FacePalm Accounting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100513/problem/G Description An owner of a small company FacePalm has recently learned that the city authorities plan to offer to small businesses to partic…
http://codeforces.com/contest/678/problem/D D. Iterated Linear Function Consider a linear function f(x) = Ax + B. Let's define g(0)(x) = x and g(n)(x) = f(g(n - 1)(x)) for n > 0. For the given integer values A, B, nand x find the value of g(n)(x) mod…
Hacking Cypher Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 490C Description Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won. Having…
Table Decorations Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 478C Description You have r red, g green and b blue balloons. To decorate a single table for the banquet you need exactl…