题意:构造出n个数 这n个数取值范围0-L,这n个数中存在取一些数之和等于k,则这样称为一种方法.给定n,k,L,求方案数. 思路:装压 每位 第1为表示这种方案能不能构成1(1表示能0表示不能)  第2为表示能不能构成2 ...  这样用d[1<<n] 的DP  像背包那样背 n次就可以 最后状态中第k位为1的就可以加上方法数. #include<cstring> #include<cstdio> #include<cmath> #include <…
你的一系列得分 先降序排列 再按0.95^(i-1)*ai 这个公式计算你的每一个得分 最后求和 Sample Input12530 478Sample Output984.1000000000 # include <iostream> # include <cstdio> # include <algorithm> # include <map> # include <cmath> # define LL long long using nam…
HDU 4906 Our happy ending pid=4906" style="">题目链接 题意:给定n个数字,每一个数字能够是0-l,要选当中一些数字.然后使得和为k,问方案 思路:状压dp.滚动数组,状态表示第i个数字.能组成的数字状态为s的状态,然后每次一个数字,循环枚举它要选取1 - min(l,k)的多少,然后进行状态转移 代码: #include <cstdio> #include <cstring> typedef long…
千寻浏览器--又一款新生浏览器今天进入各位浏览迷的视野.千寻浏览器基于IE内核,据传是由百度浏览器的上海团队操刀,在功能定位上,与目前的QQ浏览器有些相似. 千寻来自官方的解释:寻,追寻,探索,又是古代度量单位,八尺为一寻. 千寻,形容极高或极长,亦指勇于探索,不断发现的精神. 当然,各位浏览迷对他也有自己的解释,说是取自百度“众里寻他千百度”中的千寻.各位感兴趣的浏览迷可以下载体验. 版本日志: 千寻浏览器 1.0 Beta 1(524)(2014年5月27日) 1. 去除内测邀请码限制2.…
HDU 3416 Marriage Match IV (最短路径,网络流,最大流) Description Do not sincere non-interference. Like that show, now starvae also take part in a show, but it take place between city A and B. Starvae is in city A and girls are in city B. Every time starvae can…
2018 Multi-University Training Contest 2) HDU 6311 Cover HDU 6312 Game HDU 6313 Hack It HDU 6314 Matrix HDU 6315 Naive Operations HDU 6318 Swaps and Inversions…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4897 Problem Description There is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy things. Although the king used to be wise and beloved by his peopl…
题意: Given a sequence a_1,a_2,...,a_n, if we can take some of them(each a_i can only be used once), and they sum to k, then we say this sequence is a good sequence. How many good sequence are there? Given that each a_i is an integer and 0<= a_i <= L.…
http://acm.hdu.edu.cn/showproblem.php?pid=5475 An easy problem Time Limit: 8000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 755 Accepted Submission(s): 431 Problem Description One day, a useless calculator was…
HDU - 3966 Aragorn's Story Time Limit: 3000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Submit Status Description Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of ene…
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=648&page=show_problem&problem=5153 In an infinite chess board, some pawns are placed on some cells.You have a rectangular bomb that is W width and H…
插头DP基础题的样子...输入N,M<=11,以及N*M的01矩阵,0(1)表示有(无)障碍物.输出哈密顿回路(可以多回路)方案数... 看了个ppt,画了下图...感觉还是挺有效的... 参考http://www.cnblogs.com/kuangbin/archive/2012/10/02/2710343.html 以及推荐cd琦的论文ppthttp://wenku.baidu.com/view/4fe4ac659b6648d7c1c74633.html 向中学生学习~~ 感觉以后可能还会要…
Redraw Beautiful Drawings Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description Alice and Bob are playing together. Alice is crazy about art and she has visited many museums around the world. She has…
  Time Limit: 5000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Description Give you a sequence of N(N \leq 100, 000) integers : a_{1},...,a_{n}(0 < a_{i} \leq 1000, 000, 000). There are Q (Q \leq 100, 000) queries. For each query l,…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5402 Problem Description Teacher Mai is in a maze with n rows and m columns. There is a non-negative number in each cell. Teacher Mai wants to walk from the top left corner (1,1) to the bottom right corn…
题意:已知起点.圆.矩形,要求计算从起点开始,经过圆(和圆上任一点接触即可),到达矩形的路径的最短距离.(可以穿过园). 分析:没什么好的方法,凭感觉圆上的每个点对应最短距离,应该是一个凸函数,用三分来解.不过应该是分成两部分,用两次三分来解.具体原因不明,通过实验只能得出三分必须是针对一个凸函数,很明显,从0~2*pi不是一个凸函数,但同理,0~pi,pi~2*pi也不一定是个凸函数.个人认为,网络上流传的[0,pi][pi,2*pi]这种分法,并不存在合理性.继续思考= =  另外,直接暴力…
找新朋友 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10097    Accepted Submission(s): 5328 Problem Description 新年快到了,“猪头帮协会”准备搞一个聚会,已经知道现有会员N人,把会员从1到N编号,其中会长的号码是N号,凡是和会长是老朋友的,那么该会员的号码肯定和N有大于1的公…
题意:两个字符串s.t,求s和t的最长的相同的前缀和后缀 思路:先求s的next数组,再求t的next数组(即代码中ex数组,此时不是自己与自己匹配,而是与s匹配),最后看ex[len2]即可(len2为串t的长度). #include<iostream> #include<stdio.h> #include<string.h> using namespace std; #define MaxSize 50005 int _next[MaxSize],ex[MaxSiz…
Monkey and Banana Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 24147    Accepted Submission(s): 12938 Problem Description A group of researchers are designing an experiment to test the IQ of…
/* HDU 6051 - If the starlight never fade [ 原根,欧拉函数 ] | 2017 Multi-University Training Contest 2 题意: 给定 m,p, p 是素数 设 f(i) 是 满足 (x+y)^i ≡ x^i mod p 的 (x,y) 对数 且 1 ≤ x ≤ p-1 , 1 ≤ y ≤ m 求 ∑[1≤i≤p-1] i*f(i) 限制: m ≤ p-1, 2 ≤ p ≤ 1e9 分析: 设 g 为 p 的原根,则x,y可…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4900 Problem Description There is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy things. Although the king used to be wise and beloved by his peopl…
Turn the pokers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1265    Accepted Submission(s): 465 Problem Description During summer vacation,Alice stay at home for a long time, with nothing t…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5122 解题报告:定义一种排序算法,每一轮可以随机找一个数,把这个数与后面的比这个数小的交换,一直往后判断,直到后面没有比这个数小的,这样称为一轮,现在给定一个长度为n的序列,要你求,至少要经过多少轮,可以使这个序列成为有序的. 由于只能跟后面的数进行比较,所以我只要统计后面的数有比这个数小的数的个数就可以了.从后往前扫一遍,每次更新当前最小的. #include<cstdio> #include&…
思路:首先红色肯定要放在最后面.前面蓝色和绿色dp求解. dp[i][j]  表示前面(i+j) 个 有 i 个蓝色塔  j个绿色塔 能造成最大伤害. //============================================================================ // Name : 1005.cpp // Author : // Version : // Copyright : Your copyright notice // Description…
题意:求所有自己的最小公倍数的和. 该集合是  2^ai  * 3^bi 思路:线段树. 线段树中存的是  [3^b * f(b)]   f(b)表示 因子3 的最小公倍数3的部分  为 3^b的个数  那么从小到大枚举a  对于当前的  ab  ,  如果之前的b小于当前的b  那么最小公倍数就为  (2^a) *  (3^b)   个数 就为 2^x     x表示a  b 都小于当前a b的个数 .  大于的部分 就直接是  2^a   * 线段树上[b,max]的和.   求好当前更新进…
题意:给定一个环形字符串,让他把它分成k份,使得最大的字典序 最小. 思路:二分答案,首先很明显答案所有可能是 n*n种  排序可以先求出最长公共前缀,这样比较就只需要比较公共前缀的下一位就能比较出两种答案的字典序大小,这里公共前缀我用 (2*n)*(2*n) DP 求出 .(也可用后缀数组).接下来就是判断了: 这里二分出来的答案就是字典序的上界,(对于没一个位置作为起点,长度越长字典序越大)那么对于当前答案每个位置都可以求出一个能向后跳的最大值(根据如果以这个点做一个串的起点那么字典序要小于…
Problem Description There is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy things. Although the king used to be wise and beloved by his people. Now he is just like a boy in love and can’t refus…
Problem Description There is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy things. Although the king used to be wise and beloved by his people. Now he is just like a boy in love and can’t refus…
题意:给定一个长方形网格,要把它切成完全相同4个部分(这里完全相同指可以旋转平移后能重叠).把4个重叠后每个网格对应有四个数字相加,得到一种方案,所有格子中和最小就是该种方案的值,在多种方案中,最后问最大的解能使多少. 思路:首先任意一种划分可以映射到4个相同的长方形, 也就是说一种不是长方形的方案 可以转化为一种长方形的.那么我们就只需要找4个完全相同的长方形就可以.一共有以下画法: 下面画图时基于n>m.边长要满足一定条件要自己注意. #include <iostream> #inc…
题意:给定n*m个格子,每个格子能填0-k 的整数.然后给出每列之和和每行之和,问有没有解,有的话是不是唯一解,是唯一解输出方案. 思路:网络流,一共 n+m+2个点   源点 到行连流量为 所给的 当前行之和.    每行 连到每一列 一条流量为  k的边,每列到汇点连 列和.如果流量等于总和则有解,反之无解(如果列总和不等于行总和也无解).  判断方案是否唯一 找残留网络是否存在长度大于2的环即可,有环说明不唯一. #include<cstdio> #include<cstring&…