Lucky ticketsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86686#problem/J Description Everyone knows that in less than a month the Ice Hockey World Championship will start in Minsk. But few of the…
B. Modulo Sum Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/577/problem/B Description You are given a sequence of numbers a1, a2, ..., an, and a number m. Check if it is possible to choose a non-empty subsequence aij such…
http://ac.nbutoj.com/Problem/view.xhtml?id=1479 [1479] How many 时间限制: 1000 ms 内存限制: 65535 K 问题描述 There are N numbers, no repeat. All numbers is between 1 and 120, and N is no more than 60. then given a number K(1 <= K <= 100). Your task is to find o…
D. Yet Another Subarray Problem You are given an array \(a_1, a_2, \dots , a_n\) and two integers \(m\) and \(k\). You can choose some subarray \(a_l, a_{l+1}, \dots, a_{r-1}, a_r\). The cost of subarray \(a_l, a_{l+1}, \dots, a_{r-1}, a_r\) is equal…
网页链接:点击打开链接 Apart from plush toys, Imp is a huge fan of little yellow birds! To summon birds, Imp needs strong magic. There are n trees in a row on an alley in a park, there is a nest on each of the trees. In the i-th nest there are ci birds; to summ…
Partial Tree Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5534 Description In mathematics, and more specifically in graph theory, a tree is an undirected graph in which any two nodes are connected by exactly…
ACboy很喜欢玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中ACboy允许攻克M个城堡并获得里面的宝物.但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克其他某一个特定的城堡.你能帮ACboy算出要获得尽量多的宝物应该攻克哪M个城堡吗? Input每个测试实例首先包括2个整数,N,M.(1 <= M <= N <= 200);在接下来的N行里,每行包括2个整数,a,b. 在第 i 行,a 代表要攻克第 i 个城堡必须先攻克第 a 个城堡…
不会做,题解是参考网上的.感觉这道题是到好题,使得我对树形背包dp更了解了. 有几个注意的点,直接给出代码,题解以及注意点都在注释里了. #include<bits/stdc++.h> using namespace std; ; const int INF=0x3f3f3f3f; int n,m,dp[N][N],p[N][N]; vector<int> G[N],P1[N],P2[N]; //对于背包问题,有代价为0的物品麻烦在于:状态转移时候还跟自己状态有关,所以本次状态先还…