E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
ACM_背包dp
codeforces 283C Coin Troubles(
背包DP
)
题目链接:http://codeforces.com/problemset/problem/283/C 题意:给定n件物品以及每件的重量(每种物品无限多)。已知选取了一些物品的总重量为m,(x1,x2,……xn)表示一种选择中各个物品选取的数量。且这些物品是有限制的。限制有p个,每个限制给出两个数bi,ci,表示物品bi的个数必须大于物品ci的个数。求有多少种不同的选取方法? 思路:思路来自叉
·
2015-11-11 09:37
codeforces
HDU 5119 Happy Matt Friends(2014北京区域赛现场赛H题 裸
背包DP
)
虽然是一道还是算简单的DP,甚至不用滚动数组也能AC,数据量不算很大。 对于N个数,每个数只存在两个状态,取 和 不取。 容易得出状态转移方程: dp[i][j] = dp[i - 1][j ^ a[i]] + dp[i - 1][j]; dp[i][j] 的意思是,对于数列 中前 i 个数字,使得 XOR 和恰好为 j 的方案数 状态转移方程中的 dp[i - 1][j] 即表
·
2015-11-10 23:17
APP
[UVA 11517] Exact Change (
背包DP
)
Whentravellingtoremotelocations,itisoftenhelpfultobringcash,incaseyouwanttobuysomethingfromsomeonewhodoesnotacceptcreditordebitcards.Itisalsohelpfultobringavarietyofdenominationsincasethesellerdoesnot
u012015746
·
2015-11-07 22:00
HDU2126——
背包DP
(开状态)——Buy the souvenirs
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 c
·
2015-11-07 14:31
HDU
POJ2923——
背包DP
(01+状压)——Relocation
Description Emma and Eric are moving to their new house they bought after returning from their honeymoon. Fortunately, they have a few friends helping them relocate. To move the furniture, they onl
·
2015-11-07 14:30
location
HDU3466——
背包DP
——Proud Merchants
Description Recently, iSea went to an ancient country. For such a long time, it was the most wealthy and powerful kingdom in the world. As a result, the people in this country are still very proud e
·
2015-11-07 14:30
ant
HDU2639——
背包DP
(K最优解)——Bone Collector II
Description The title of this problem is familiar,isn't it?yeah,if you had took part in the "Rookie Cup" competition,you must have seem this title.If you haven't seen it before,it doesn't
·
2015-11-07 14:29
Collector
POJ2184——
背包DP
——Cow Exhibition
Description "Fat and docile, big and dumb, they look so stupid, they aren't much fun..." - Cows with Guns by Dana Lyons The cows want to prove to the public that the
·
2015-11-07 14:28
poj
HDU2546——
背包DP
——饭卡
Description 电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则无法购买(即使金额足够)。所以大家都希望尽量使卡上的余额最少。 某天,食堂中有n种菜出售,每种菜可购买一次。已知每种菜的价格以及卡上的余额,问最少可使卡上的余额为多少。 &nb
·
2015-11-07 14:27
HDU
UVA624——
背包DP
(回溯)——CD
Description You have a long drive by car ahead. You have a tape recorder, but unfortunately your best music is on CDs. You need to have it on tapes so the problem to solve is: you have a ta
·
2015-11-07 14:27
uva
ACM_
高次同余方程
/*poj3243 *解决高次同余方程的应用,已知X^Y=KmodZ,及X,Z,K的值,求Y的值 */ #include #include #include usingnamespacestd; #definelint__int64 #defineMAXN131071 structHashNode{lintdata,id,next;}; HashNodehash[MAXN=1) { if(b&1
xiaotan1314
·
2015-11-07 10:00
高次同余方程
POJ2063——
背包DP
(完全背包)—— Investment
Description John never knew he had a grand-uncle, until he received the notary's letter. He learned that his late grand-uncle had gathered a lot of money, somewhere in South-America, and that John w
·
2015-11-07 10:45
poj
POJ3260——
背包DP
(多重)——The Fewest Coins
Description Farmer John has gone to town to buy some farm supplies. Being a very efficient man, he always pays for his goods in such a way that the smallest number of coins changes hands, i.e., the
·
2015-11-07 10:44
poj
POJ1787——
背包DP
(特定状态+回溯)——Charlie's Change
Description Charlie is a driver of Advanced Cargo Movement, Ltd. Charlie drives a lot and so he often buys coffee at coffee vending machines at motorests. Charlie hates change. That is basically the
·
2015-11-07 10:43
change
[LeetCode39]Combination Sum 和[LeetCode40]Combination Sum II
一开始想到用
背包DP
做,用DP的好处是速度快。但打印结果比较麻烦。DP比较适合打印总共有几种情况。所以就用DFS来做。
lfdanding
·
2015-11-06 18:00
LeetCode
DFS
ACM_
扩展欧几里德算法
/* 扩展欧几里德算法 基本算法:对于不完全为0的非负整数a,b,gcd(a,b)表示a,b的最大公约数,必然存在整数对x,y,使得gcd(a,b)=ax+by。 证明:设a>b。 1,显然当b=0,gcd(a,b)=a。此时x=1,y=0; 2,ab!=0时 设ax1+by1=gcd(a,b); bx2+(amodb)y2=gcd(b,amodb); 根据朴素的欧几里德原理有gcd
xiaotan1314
·
2015-11-06 14:00
算法
ACM
gcd
HDU 4739 Zhuge Liang's Mines (状态压缩+
背包DP
)
题意 给定平面直角坐标系内的N(N <= 20)个点,每四个点构成一个正方形可以消去,问最多可以消去几个点。 思路 比赛的时候暴力dfs+O(n^4)枚举写过了……无意间看到有题解用状压DP(这才是正解吧T_T),然后自己才恍然大悟- -…… 点不多嘛,用一个20位的整数表示各个点。先O(n^4)枚举出所有正方形情况,然后把这20位当背包,每种情况的二进制位当物品,做01背包就可以了. 似乎
·
2015-11-02 17:16
HDU
HDU 4739 Zhuge Liang's Mines (状态压缩+
背包DP
)
题意 给定平面直角坐标系内的N(N <= 20)个点,每四个点构成一个正方形可以消去,问最多可以消去几个点。 思路 比赛的时候暴力dfs+O(n^4)枚举写过了……无意间看到有题解用状压DP(这才是正解吧T_T),然后自己才恍然大悟- -…… 点不多嘛,用一个20位的整数表示各个点。先O(n^4)枚举出所有正方形情况,然后把这20位当背包,每种情况的二进制位当物品,做01背包就可以了. 似乎
·
2015-11-02 17:53
HDU
URAL1224——
背包DP
+回溯——Gentlemen
Description Let's remember one old joke: Once a gentleman said to another gentleman:— What if we play cards?— You know, I haven't played cards for ten years…— And I haven't played for fifteen
·
2015-11-02 16:05
dp
BZOJ 1618: [Usaco2008 Nov]Buying Hay 购买干草( dp )
无限
背包dp
..
·
2015-11-02 12:51
USACO
BZOJ 1708: [Usaco2007 Oct]Money奶牛的硬币( dp )
背包dp
.. -------------------------------------------------------------------------------- #include&
·
2015-11-02 12:43
USACO
BZOJ 1578: [Usaco2009 Feb]Stock Market 股票市场(
背包dp
)
我们假设每天买完第二天就卖掉( 不卖出也可以看作是卖出后再买入 ), 这样就是变成了一个完全背包问题了, 股票价格为体积, 第二天的股票价格 - 今天股票价格为价值.... 然后就一天一天dp... --------------------------------------------------------------- #include<cstdio>
·
2015-11-01 14:16
USACO
BZOJ 2287: 【POJ Challenge】消失之物(
背包dp
)
虽然A掉了但是时间感人啊.... f( x, k ) 表示使用前 x 种填满容量为 k 的背包的方案数, g( x , k ) 表示使用后 x 种填满容量为 k 的背包的方案数. 丢了第 i 个, 要填满容量为 k 的背包 , 则 ans( i , k ) = ∑ f( i - 1, h ) * g( i + 1 , k - h ) ( 0 <= h <= k ) 这样就转化
·
2015-11-01 14:08
poj
[
ACM_
模拟] UVA 12504 Updating a Dictionary [字符串处理 字典增加、减少、改变问题]
Updating a Dictionary In this problem, a dictionary is collection of key-value pairs, where keys are lower-case letters, and values are non-negative integers. Given
·
2015-11-01 10:30
字符串处理
[
ACM_
水题] UVA 12502 Three Families [2人干3人的活后分钱,水]
Three Families Three families share a garden. They usually clean the garden together at the end of each week, but last week, family C was on holiday, so family A sp
·
2015-11-01 10:29
ACM
[
ACM_
模拟] UVA 12503 Robot Instructions [指令控制坐标轴上机器人移动 水]
Robot Instructions You have a robot standing on the origin of x axis. The robot will be given some instructions. Your task is to predict its position after executin
·
2015-11-01 10:29
struct
[
ACM_
数据结构] POJ2352 [树状数组稍微变形]
Description Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star be an amount of the stars tha
·
2015-10-31 11:37
数据结构
[
ACM_
图论] ZOJ 3708 [Density of Power Network 线路密度,a->b=b->a去重]
The vast power system is the most complicated man-made system and the greatest engineering innovation in the 20th century. The following diagram shows a typical 14 bus power system. In
·
2015-10-31 11:36
NetWork
[
ACM_
水题] ZOJ 3712 [Hard to Play 300 100 50 最大最小]
MightyHorse is playing a music game called osu!. After playing for several months, MightyHorse discovered the way of calculating score in osu!: 1. While p
·
2015-10-31 11:36
play
[
ACM_
暴力][
ACM_
几何] ZOJ 1426 Counting Rectangles (水平竖直线段组成的矩形个数,暴力)
Description We are given a figure consisting of only horizontal and vertical line segments. Our goal is to count the number of all different rectangles formed by these segments. As an example, the n
·
2015-10-31 11:36
count
[
ACM_
动态规划] UVA 12511 Virus [最长公共递增子序列 LCIS 动态规划]
Virus We have a log file, which is a sequence of recorded events. Naturally, the timestamps are strictly increasing. However, it is infected by a virus, so random
·
2015-10-31 11:36
动态规划
[
ACM_
动态规划] hdu 1176 免费馅饼 [变形数塔问题]
Problem Description 都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。由于gameboy平时老
·
2015-10-31 11:36
动态规划
[
ACM_
模拟] ACM - Draw Something Cheat [n个长12的大写字母串,找出交集,按字母序输出]
Description Have you played Draw Something? It's currently one of the hottest social drawing games on Apple iOS and Android Devices! In this game, you and your friend play in turn. You
·
2015-10-31 11:36
ACM
[
ACM_
数学] LA 3708 Graveyard [墓地雕塑 圈上新加点 找规律]
Description Programming contests became so popular in the year 2397 that the governor of New Earck -- the largest human-inhabited planet of the galaxy -- opened a special Alley of
·
2015-10-31 11:36
ACM
[
ACM_
水题] UVA 11292 Dragon of Loowater [勇士斗恶龙 双数组排序 贪心]
Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shores of Rellau Creek in central Loowater had always been a prime breeding ground for g
·
2015-10-31 11:36
water
[
ACM_
模拟][
ACM_
数学] LA 2995 Image Is Everything [由6个视图计算立方体最大体积]
Description Your new company is building a robot that can hold small lightweight objects. The robot will have the intelligence to determine if an object is light enough to hold. It
·
2015-10-31 11:36
image
[
ACM_
图论] The Perfect Stall 完美的牛栏(匈牙利算法、最大二分匹配)
描述 农夫约翰上个星期刚刚建好了他的新牛棚,他使用了最新的挤奶技术。不幸的是,由于工程问题,每个牛栏都不一样。第一个星期,农夫约翰随便地让奶牛们进入牛栏,但是问题很快地显露出来:每头奶牛都只愿意在她们喜欢的那些牛栏中产奶。上个星期,农夫约翰刚刚收集到了奶牛们的爱好的信息(每头奶牛喜欢在哪些牛栏产奶)。一个牛栏只能容纳一头奶牛,当然,一头奶牛只能在一个牛栏中产奶。 给出奶牛们的爱好的信息,计算最
·
2015-10-31 11:35
ACM
[
ACM_
搜索] ZOJ 1103 || POJ 2415 Hike on a Graph (带条件移动3盘子到同一位置的最少步数 广搜)
Description "Hike on a Graph" is a game that is played on a board on which an undirected graph is drawn. The graph is complete and has all loops, i.e. for any two locations there is exactly
·
2015-10-31 11:35
Graph
[
ACM_
图论] Fire Net (ZOJ 1002 带障碍棋盘布炮,互不攻击最大数量)
Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall. A blockhouse is a small cas
·
2015-10-31 11:35
ACM
[
ACM_
图论] Sorting Slides(挑选幻灯片,二分匹配,中等)
Description Professor Clumsey is going to give an important talk this afternoon. Unfortunately, he is not a very tidy person and has put all his transparencies on one big heap. Before giving the talk
·
2015-10-31 11:35
sort
[
ACM_
搜索] Triangles(POJ1471,简单搜索,注意细节)
Description It is always very nice to have little brothers or sisters. You can tease them, lock them in the bathroom or put red hot chili in their sandwiches. But there is also a time when all meanne
·
2015-10-31 11:35
ACM
[
ACM_
动态规划] ZOJ 1425 Crossed Matchings(交叉最大匹配 动态规划)
Description There are two rows of positive integer numbers. We can draw one line segment between any two equal numbers, with values r, if one of them is located in the first row and the other one is
·
2015-10-31 11:35
match
[
ACM_
搜索] POJ 1096 Space Station Shielding (搜索 + 洪泛算法Flood_Fill)
Description Roger Wilco is in charge of the design of a low orbiting space station for the planet Mars. To simplify construction, the station is made up of a series of Airtight Cubical Modules (ACM's
·
2015-10-31 11:35
ACM
[
ACM_
几何] Transmitters (zoj 1041 ,可旋转半圆内的最多点)
Description In a wireless network with multiple transmitters sending on the same frequencies, it is often a requirement that signals don't overlap, or at least that they don't conflict. One way of a
·
2015-10-31 11:35
ACM
[
ACM_
模拟] The Willy Memorial Program (poj 1073 ,联通水管注水模拟)
Description Willy the spider used to live in the chemistry laboratory of Dr. Petro. He used to wander about the lab pipes and sometimes inside empty ones. One night while he was in a pipe, he fell as
·
2015-10-31 11:35
ACM
[
ACM_
其他] Square Ice (poj1099 规律)
Description Square Ice is a two-dimensional arrangement of water molecules H2O, with oxygen at the vertices of a square lattice and one hydrogen atom between each pair of adjacent oxygen atoms. The
·
2015-10-31 11:35
ACM
[
ACM_
图论] Highways (变形说法的最小生成树)
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=28972#problem/C 题目给出T种情况,每种情况有n个城镇,接下来每一行是第i个城镇到所有城镇的距离(其实就是个可达矩阵)。 求建设一条公路联通所有城镇并且要求最长的一段最小(其实就是最小生成树)!代码如下: #include<
·
2015-10-31 11:34
最小生成树
[
ACM_
数学] Counting Solutions to an Integral Equation (x+2y+2z=n 组合种类)
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27938#problem/E 题目大意:Given, n, count the number of solutions to the equation x+2y+2z=n, where x,y,z,n are non negative inte
·
2015-10-31 11:34
count
[
ACM_
几何] The Deadly Olympic Returns!!! (空间相对运动之最短距离)
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=28235#problem/B 题目大意: 有两个同时再空间中匀速运动的导弹,告诉一个时间以及各自的初始坐标和该时间时的坐标,求运动过程中的最短距离 解题思路: 求出相对初位置、相对速度,则答案就是原点到射线型轨迹的距离,注意是射线!!!
·
2015-10-31 11:34
return
[
ACM_
几何] F. 3D Triangles (三维三角行相交)
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=28235#problem/A 题目大意:给出三维空间两个三角形三个顶点,判断二者是否有公共点,三角形顶点、边、内部算三角形的一部分。 解题思路:见模板 //**********************************************
·
2015-10-31 11:34
ACM
上一页
3
4
5
6
7
8
9
10
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他