2015 多校联赛 ——HDU5389(dp)】的更多相关文章

Sample Input 4 3 9 1 1 2 6 3 9 1 2 3 3 5 2 3 1 1 1 1 1 9 9 9 1 2 3 4 5 6 7 8 9   Sample Output 1 0 10 60 题意: 已知有两个门,要求将人分为两组,两组的“和”分别等于两个门的数字,当然也可以全部进入一个门 思路:(NeverMoreH) 如果能找到满足题意的解,一定满足a和b的和等于n个人的标号的和,所以我们只需要判断n个人的标号组成a的情况有多少(或者只判断b,一样),同时还要注意可以把n个…
Sample Input 1 100 2 10 2 1 20 1 1   Sample Output 21 题意:共有m元钱和n种东西,求每种单价p,而且你买x个该种物品可以得到Ax+B个,求m元钱最多能得到多少. 思路:先01背包处理出A+B的情况,再用完全背包往里算加A能得到的情况. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cm…
Sample Input 2 00?0 1 2 4 8 ???? 1 2 4 8   Sample Output Case #1: 12 Case #2: 15 ?部分可以是0  or  1,将二进制转化成格雷码后,哪里是 1 就可以取相应的数,求得到数的最大值 ①:判断连续的?的个数奇偶不同,两边是否相等.在有时会去掉一个最小值.(感觉写着很麻烦) #include <iostream> #include <cstdio> #include <vector> #inc…
Zero Escape Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 289    Accepted Submission(s): 135 Problem Description Zero Escape, is a visual novel adventure video game directed by Kotaro Uchiko…
Virtual Participation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 237    Accepted Submission(s): 56 Special Judge Problem Description As we know, Rikka is poor at math. Yuta is worrying abo…
Connect the Graph Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 108    Accepted Submission(s): 36 Special Judge Problem Description Once there was a special graph. This graph had n vertices a…
Tricks Device Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1977    Accepted Submission(s): 509 Problem Description Innocent Wu follows Dumb Zhang into a ancient tomb. Innocent Wu’s at the en…
Crazy Bobo Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Total Submission(s): 1215    Accepted Submission(s): 366 Problem Description Bobo has a tree,whose vertices are conveniently labeled by 1,2,...,n.Each nod…
Fantasy magicians usually gain their ability through one of three usual methods: possessing it as an innate talent, gaining it through study and practice, or receiving it from another being, often a god, spirit, or demon of some sort. Some wizards ar…
Solve this interesting problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 422    Accepted Submission(s): 98 Problem Description Have you learned something about segment tree? If not, don’t…
Painter Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 895    Accepted Submission(s): 408 Problem Description Mr. Hdu is an painter, as we all know, painters need ideas to innovate , one day,…
Your current task is to make a ground plan for a residential building located in HZXJHS. So you must determine a way to split the floor building with walls to make apartments in the shape of a rectangle. Each built wall must be paralled to the buildi…
Delicious Apples Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others) Total Submission(s): 1371    Accepted Submission(s): 448 Problem Description There are n apple trees planted along a cyclic road, which is L metres…
Friends Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 163    Accepted Submission(s): 61 Problem Description There are n people and m pairs of friends. For every pair of friends, they can choo…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 593    Accepted Submission(s): 164 Problem Description There are n circles on a infinitely large table.With every two circle, either one contains…
OO’s Sequence Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 449    Accepted Submission(s): 158 Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the nu…
CRB has a tree, whose vertices are labeled by 1, 2, …, N. They are connected by N – 1 edges. Each edge has a weight. For any two vertices u and v(possibly equal), f(u,v) is xor(exclusive-or) sum of weights of all edges on the path from u to v. CRB’s…
Problem Description CRB has two strings s and t. In each step, CRB can select arbitrary character c of s and insert any character d (d ≠ c) just after it. CRB wants to convert s to t. But is it possible?   Input There are multiple test cases. The fir…
For each test case, in the first line, you should print the maximum sum. In the next line you should print a string consisting of "L","R","U" and "D", which represents the path you find. If you are in the cell (x,y)…
Sample Input 5 2 -2 0 2 0 -2 0 5 2 3 2 3 3 3 3   Sample Output 12 5 求最多多少序列满足,前半部分满足d(j+1) = d(j)+d1,后半部分d(j+1)= d(j)+d2,或者只满足其中一个. 假设可以找出长度为x的序列,则有x-1 + x-2 + .... + 1种.所以从头到尾找一遍即可. #include <iostream> #include <cstdio> using namespace std; t…
Sample Input 3 0 0 0 3 0 1 5 0 1 0 0 1 1 0 1 0 0   Sample Output Case #1: 0 0 0 Case #2: 0 1 0 2 有0,1两个操作,0  x代表添加从x 到 x + i(带表第i次添加)的线段,每次添加时问被其覆盖的线段有多少. 1  x代表删除第i次添加的. 思路:每一次添加后,求出小于x的左节点个数x1,小于等于y的右节点个数x2. x2- x1即可 改变单个节点,所以树状数组更加合适 #include<iost…
Sample Input 1 3 5 2 2 1 2 3 3 2 1 3 3 3 3 3 3 3 3 3 3 H 2 3 L 2 2 H 3 3 H 1 3 L 2 3   Sample Output 5 2 4 3 1 给你一个初始矩阵和目标矩阵,包含‘L’ , ' H' 两个操作, ‘L x y’  表示把第x列全赋值成y, ‘Hx y’  表示把第x行全赋值成y. 求怎样的顺序可以得出目标矩阵. 倒着求解,在目标矩阵上你肯定能找到最后一个操作,这样倒推出答案即可 #include<iost…
Sample Input 1 5 6 orz sto kirigiri danganronpa ooooo o kyouko dangan ronpa ooooo ooooo   Sample Output 1 1 0 3 7   题意:给n个母串,给m个匹配串,求每个母串依次和匹配串匹配,能得到的数目和 开始用KMP超时了,突然看见AC,把模板改一下就过了- - #include<iostream> #include<cstdio> #include<cstring>…
Sample Input 1 10 2 3 4 4 3 2 2 3 4 4   Sample Output Case #1: 9 要求找出一段数字. 将其分成3部分,第①和第②部分成回文字串,第②和第③部分成回文字串 用manacher算出各个点的回文后字串长度,然点枚举和半径(后部分稍不注意就超时  - -!!) #include <cstdio> #include <iostream> #include <algorithm> #define MAXN 100010…
Problem Description In this problem, we should solve an interesting game. At first, we have an integer n, then we begin to make some funny change. We sum up every digit of the n, then insert it to the tail of the number n, then let the new number be…
Sample Input 4 8 4 1 3 2 2 1 0 3 5 3 6 4 2 1 7 6 8 3 3 2 0 5 0 3 6 4 5 2 7 7 6 7 6 8 2 2 3 3 3 0 0 2 7 4 3 6 3 2 2 5 8 5 6 5 3 3 1 2 4 6 7 7 6 5 4 3 5   Sample Output 7 1 7 6 5 2 4 3 8 8 4 6 3 1 2 5 8 7 7 3 6 7 1 5 2 8 4 0 1 2 3 4 5 6 7 8 找出能约出最多人的顺序…
Problem Description soda has a set S with n integers {1,2,…,n}. A set is called key set if the sum of integers in the set is an even number. He wants to know how many nonempty subsets of S are key set.   Input There are multiple test cases. The first…
Each soda has some candies in their hand. And they want to make the number of candies the same by doing some taking and giving operations. More specifically, every two adjacent soda x and y can do one of the following operations only once: 1. x-th so…
Problem Description As we all kown, MZL hates the endless loop deeply, and he commands you to solve this problem to end the loop. You are given an undirected graph with n vertexs and m edges. Please direct all the edges so that for every vertex in th…
Problem Description MZL is a mysterious mathematician, and he proposed a mysterious function at his young age. Stilwell is very confused about this function, and he need your help. First of all, given n positive integers Ai and Ai≥Ai+1. Then, generat…