给出n个点,m条边,入口s和出口t,对于每条边有两个值a,b,如果保留这条边需要花费:否则,移除这条边需要花费b. 题目要求用最小费用构造一个有向图满足以下条件: 1.只有一个入口和出口 2.所有路都是唯一方向 3.对于入口s,它的出度 = 它的入度 + 1 4.对于出口t,它的入度 = 它的出度 + 1 5.除了s和t外,其他点的入度 = 其出度 最后如果可以构造,输出最小费用:否则输出impossibe. 题解: 对于所有的边(u,v,a,b)我们先进行保留. 因为题目要求3和4.我们虚拟添…
Random Maze Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1669    Accepted Submission(s): 682 Problem Description In the game “A Chinese Ghost Story”, there are many random mazes which have s…
意甲冠军: 一个"随机图"它被定义为具有以下性质如: 一个入口和一个出口 有向图 对于入口  出度比入度大1 对于出口  入度比出度大1 对于其它点  入度等于出度 现给出一幅有向图  每条边有2个决策--留下.扔掉  分别花费a和b  问  假设用最少的费用改造出"随机图" 思路: 网络流不错的题目  假设做过"混合图欧拉回路"(后文把这个问题成为p)那个zoj的题的话  这道题会有启示 来回顾p的做法  先将无向边任意定向  再利用度来将点划…
题目地址:pid=1853">HDU1853 费用流果然好奇妙. .还能够用来推断环...假设每一个点都是环的一部分并且每一个点仅仅能用到一次的话,那每一个点的初度入度都是1,这就能够利用网络流来解决,仅仅要拆点令其流量为1.就限制了每一个点仅仅能用一次,每次左边的连到右边的.就相当于左边点的一次初度和右边的点的一次入度.非常easy想象出来. 最后仅仅要推断总流量是否为n就可以.由于假设总流量为n的话.说明每一个点都出了一次度.每一个点都入了一次度.并且由于拆点的流量限制.充分说明了每一…
比赛的时候就预感到这题能出,但是会耗时比较多.结果最后是出了,但是有更简单的题没出. 是不是错误的决策呢?谁知道呢 题目意思: 定义f(x) = x分解质因数出来的因子个数 如 x = p0 * p0 * p0 * p1 * p2,则f(x) = 5 特殊的, f(1) = 0 求 i = [1..n], j = [1..m] 组成的n*m组(i, j)对中,有多少组f( gcd(i,j) ) <= p 考虑简化版本,p = 0,即求有多少组 gcd(i,j) == 1. 见HDU 1695 h…
Just Random Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3932 Accepted Submission(s): 1276 Problem Description Coach Pang and Uncle Yang both love numbers. Every morning they play a game with n…
题目大概说,给一张图,删除其中一些单向边,使起点s出度比入度多1,终点t入度比出度多1,其他点出度等于入度.其中删除边的费用是bi,保留边的费用是ai,问完成要求最小的费用是多少. 一开始我想到和混合图欧拉回路(POJ1637)的类似构造方法: 假设所有边一开始都是保留的,算出各个点的入度和出度,另外s点的出度-1,t点的入度-1: 然后把出度-入度等于正数的点源点向其连一条容量为出度-入度的边,等于负数的点其向汇点连一条容量为入度-出度的边 这样就是要通过删除边使那些与源汇相连的边满流,这样就…
首先 m = 1 时 ans = 0对于 m > 1 的 情况 由于 1 到 m-1 中所有和m互质的数字,在 对m的乘法取模 运算上形成了群 ai = ( 1<=a<m && gcd(a,m) == 1 ) 所以 对于 a 必然存在b = a^(-1) = inv(a) 使得 a * b = 1 (mod m) 这里存在两种情况 a != b 那么最后的连乘式中a b均出现一次,相乘得1 a == b 那么最后的连乘式中只出现一个a 实际上所有 a = inv(a) 的…
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并查集======================================[HDU]1213   How Many Tables   基础并查集★1272   小希的迷宫   基础并查集★1325&&poj1308  Is It A Tree?   基础并查集★1856   More i…
=============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many Tables 基础并查集★ 1272 小希的迷宫 基础并查集★ 1325&&poj1308 Is It A Tree? 基础并查集★ 1856 More is better 基础并查集★ 1102 Constructing Roads 基础最小生成树★ 1232 畅通工程 基础并查集★ 123…
=============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many Tables 基础并查集★ 1272 小希的迷宫 基础并查集★ 1325&&poj1308 Is It A Tree? 基础并查集★ 1856 More is better 基础并查集★ 1102 Constructing Roads 基础最小生成树★ 1232 畅通工程 基础并查集★ 123…
=============================以下是最小生成树+并查集====================================== [HDU] How Many Tables 基础并查集★ 小希的迷宫 基础并查集★ &&poj1308 Is It A Tree? 基础并查集★ More is better 基础并查集★ Constructing Roads 基础最小生成树★ 畅通工程 基础并查集★ 还是畅通工程 基础最小生成树★ 畅通工程 基础最小生成树★ 畅通…
因为是circle sequence,可以在序列最后+序列前n项(或前k项);利用前缀和思想,预处理出前i个数的和为sum[i],则i~j的和就为sum[j]-sum[i-1],对于每个j,取最小的sum[i-1],这就转成一道单调队列了,维护k个数的最小值. ---------------------------------------------------------------------------------- #include<cstdio> #include<deque&…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3706 Second My Problem First Time Limit: 12000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description Give you three integers n, A and B. Then we define Si = Ai mod B and…
Max Sum of Max-K-sub-sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5335    Accepted Submission(s): 1939 Problem Description Given a circle sequence A[1],A[2],A[3]......A[n]. Circle se…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=3339 In Action Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7869    Accepted Submission(s): 2674 Problem Description Since 1945, when the first…
题目链接:[http://acm.hdu.edu.cn/showproblem.php?pid=3339] In Action Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5951    Accepted Submission(s): 1998 Problem Description Since 1945, when the firs…
In Action Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3869    Accepted Submission(s): 1237 Problem Description Since 1945, when the first nuclear bomb was exploded by the Manhattan Project t…
Marriage Match IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2470    Accepted Submission(s): 742 Problem Description Do not sincere non-interference. Like that show, now starvae also take…
最短路+01背包 In Action Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3857    Accepted Submission(s): 1229 Problem Description Since 1945, when the first nuclear bomb was exploded by the Manhattan…
In Action Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5102    Accepted Submission(s): 1696 Problem Description Since 1945, when the first nuclear bomb was exploded by the Manhattan Project t…
In Action Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5472    Accepted Submission(s): 1843 Problem Description Since 1945, when the first nuclear bomb was exploded by the Manhattan Project t…
Max Sum of Max-K-sub-sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7034    Accepted Submission(s): 2589 Problem Description Given a circle sequence A[1],A[2],A[3]......A[n]. Circle se…
Max Sum of Max-K-sub-sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5084    Accepted Submission(s): 1842 Problem Description Given a circle sequence A[1],A[2],A[3]......A[n]. Circle s…
Marriage Match IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4381    Accepted Submission(s): 1310 Problem Description Do not sincere non-interference.Like that show, now starvae also take p…
题目链接:https://vjudge.net/problem/HDU-3416 Marriage Match IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4710    Accepted Submission(s): 1412 Problem Description Do not sincere non-interferenc…
题目链接:https://vjudge.net/problem/HDU-3338 Kakuro Extension Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2419    Accepted Submission(s): 840Special Judge Problem Description If you solved probl…
In Action Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4859    Accepted Submission(s): 1600 Problem Description Since 1945, when the first nuclear bomb was exploded by the Manhattan Project…
原文:http://tieba.baidu.com/p/2596809144 #include<iostream.h> #include"time.h" #include"stdlib.h" const char road = ' '; const char wall = 'w'; ; ; ; const char path = '.'; ; ; ; ; const char walked =wall; void Outmaze(int size,cha…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4067 思路:很神奇的建图,参考大牛的: 如果人为添加t->s的边,那么图中所有顶点要满足的条件都是一样的了,我们以此为目的来建图. 对于每条边,我们只有两种操作,要么保留要么删除,那么先假设两种操作都能满足条件,我们就可以选择花费小的操作来执行,最后再根据实际情况调整.首先不加入任何边,在添加或删除(不加入)边的过程中,对每个顶点v记录in[v]为其当前入度,out[v]为其出度,sum为当前的总花…