题目地址:HDU 3468 这道题的关键在于能想到用网络流.然后还要想到用bfs来标记最短路中的点. 首先标记方法是,对每个集合点跑一次bfs,记录全部点到该点的最短距离.然后对于随意一对起始点来说,仅仅要这个点到起点的最短距离+该点到终点的最短距离==起点到终点的最短距离,就说明这点在某条从起点到终点的最短路上. 然后以集合点建X集,宝物点建Y集构造二分图,将从某集合点出发的最短路中经过宝物点与该集合点连边.剩下的用二分匹配算法或最大流算法都能够.(为什么我的最大流比二分匹配跑的还要快....…
题意: A-Z&&a-z 表示 集结点 从A点出发经过 最短步数 走到下一个集结点(A的下一个集结点为B ,Z的下一个集结点为a) 的路上遇到金子(*)则能够捡走(一个点仅仅能捡一次) 求从A点出发走遍全部的的集结点 最多能捡多少金子 思路:先对于第 i 个集结点用BFS求出 对于每一个点从该集结点所需的步数  为D[ I ] [ t ] 对于随意一个金子若  两个相邻的集结点的最短步数=其到该金子的步数和 则建一条边(能够拿) 然后最大流求 #include <cstdio>…
HDU 3338 Kakuro Extension (网络流,最大流) Description If you solved problem like this, forget it.Because you need to use a completely different algorithm to solve the following one. Kakuro puzzle is played on a grid of "black" and "white" ce…
HDU 4280 Island Transport(网络流,最大流) Description In the vast waters far far away, there are many islands. People are living on the islands, and all the transport among the islands relies on the ships. You have a transportation company there. Some route…
题目链接:pid=3641">传送门 题意: 求最小的 ( x! ) = 0 mod (a1^b1*a2^b2...an^bn) 分析: 首先吧a1~an进行素因子分解,然后统计下每一个质因子的指数.因为随着x的增大,质因子的个数是逐渐添加的 因此我们能够二分x.对x!进行素因子分解推断是否满足条件.然后求出最小的就能够了. 代码例如以下: #include <iostream> #include <cstring> #include <algorithm&g…
/** 大意:给定一组ai,bi . m = a1^b1 *a2^b2 * a3^ b3 * a4^b4*...*ai^bi 求最小的x!%m =0 思路: 将ai 质因子分解,若是x!%m=0 那么x! 质因子分解之后 质因子的个数一定大于等于m的个数.二分求解可得 注意: 二分时,需要将,上下限 设定好,low =0: high = 1ll<<60; **/ #include <iostream> #include <cstring> #include <cm…
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3605 本来打算昨天写两道题的,结果这个题卡住了,最后才发现是最后的推断条件出错了,推断满流的条件应该是与n的比較,居然写成与全部星球总容量的比較了.(近期大脑短路..) 这题也不是全然自己想的,没想到缩点这一技巧,由于n的数据范围太大,普通的建图方法会超时超内存,须要缩点,由于对于每一个点来说,一共仅仅有2^10种方法,而最多一共同拥有10W个点,显然有非常多点是反复的,这时能够採取缩点的方法,将反…
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…
HDU 3081 Marriage Match II (网络流,最大流,二分,并查集) Description Presumably, you all have known the question of stable marriage match. A girl will choose a boy; it is similar as the game of playing house we used to play when we are kids. What a happy time as…
HDU 3605 Escape (网络流,最大流,位运算压缩) Description 2012 If this is the end of the world how to do? I do not know how. But now scientists have found that some stars, who can live, but some people do not fit to live some of the planet. Now scientists want you…