HDU
feng_zhiyu
这个作者很懒,什么都没留下…
展开
-
网络流~最大流算法模板题
Ford-Fulkerson算法 记F为最大流的流量。 通过深度优先搜索寻找增广路,并沿着它增广。 时间复杂度 O(FE) E为边的条数模板题:【hdu 1532】 (Ford-Fulkerson算法和Dinic算法)Ford-Fulkerson算法 模板代码:#include <cstdio>#include <iostream>#includ...原创 2018-02-02 18:53:47 · 836 阅读 · 0 评论 -
(hdu1573)X问题(中国剩余定理+扩展欧几里得算法)
X问题Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6595 Accepted Submission(s): 2287Problem Description 求在小于等于N的正整数中有多少个X满足:X mod a[0] = b[原创 2017-07-26 09:42:06 · 437 阅读 · 0 评论 -
(hdu3123)GCC(观察数据范围)
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 5137 Accepted Submission(s): 1714Problem Description The GNU Compiler Collection (usually原创 2017-07-29 10:38:57 · 345 阅读 · 0 评论 -
(hdu2588)GCD(欧拉函数)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2320 Accepted Submission(s): 1174Problem Description The greatest common divisor GCD(a,b) o原创 2017-07-29 10:52:57 · 485 阅读 · 0 评论 -
(hdu1787)GCD Again(欧拉函数)
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3654 Accepted Submission(s): 1615Problem Description Do you have spent some time to think a原创 2017-07-29 11:01:12 · 375 阅读 · 0 评论 -
(hdu1394)Minimum Inversion Number (树状数组/线段树/归并排序)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 20737 Accepted Submission(s): 12434Problem Description The inversion number of a given n...原创 2017-07-28 19:45:47 · 413 阅读 · 0 评论 -
(hdu6033)Add More Zero(数学,取对数)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1409 Accepted Submission(s): 917Problem Description There is a youngster known for amateu原创 2017-08-06 15:20:27 · 338 阅读 · 0 评论 -
(hdu6043)KazaQ's Socks(水)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1256 Accepted Submission(s): 751Problem Description KazaQ wears socks everyday.At the beg原创 2017-08-06 16:04:12 · 336 阅读 · 0 评论 -
(hdu3790)最短路径问题(dijkstra算法)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 27921 Accepted Submission(s): 8307Problem Description给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起原创 2017-07-28 20:13:02 · 419 阅读 · 0 评论 -
(hdu1534)Schedule Problem(差分约束+SPFA算法)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1961 Accepted Submission(s): 896 Special JudgeProblem Description A project can be divided原创 2017-07-26 20:01:07 · 508 阅读 · 0 评论 -
(hdu4135)Co-prime(容斥定理+队列)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5189 Accepted Submission(s): 2070Problem Description Given a number N, you are asked to cou原创 2017-07-27 10:42:09 · 399 阅读 · 0 评论 -
(hdu 2089)不要62(数位DP)
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2089Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 46291 Accepted Submission(s): 17518Problem原创 2017-09-23 10:10:47 · 397 阅读 · 0 评论 -
hdu 4398 X mod f(x)(数位DP)
Time limit2000 msMemory limit32768 kBOSWindowsere is a function f(x): int f ( int x ) { if ( x == 0 ) return 0; return f ( x / 10 ) + x % 10; } Now, you want to know, in a giv原创 2017-09-16 10:28:14 · 753 阅读 · 0 评论 -
hdu 4734 F(x)(数位dp)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=4734题意:我们定义十进制数x的权值为f(x) = a(n)*2^(n-1)+a(n-1)*2(n-2)+…a(2)*2+a(1)*1,a(i)表示十进制数x中第i位的数字。给出a,b,求出0~b有多少个不大于f(a)的数。分析:数位dp。 dp[i][j]表示i位数比j小的数的个数, 另外注意状态转原创 2017-12-13 20:00:39 · 306 阅读 · 0 评论 -
【hdu 5350 2015多校赛】MZL's munhaff function (哈夫曼数,优先队列)
题意:大概就是对给出的序列Ai,求最小的哈夫曼树分析:对于最小哈夫曼树的求解,只需要维护一个堆,每次从堆中取出最小的两个元素a+b,将a+b累加入答案,并把a+b入堆。 因为priority_queue是基于堆(大顶堆)实现的, 可以加一个greater 实现小顶堆 注意爆Int 用long long 代码:#include <cstdio>#include &l...原创 2018-02-10 20:33:30 · 336 阅读 · 0 评论 -
【hdu 5351 MZL's Border 2015多校赛5 】( 高精度 模板)
题意:f(1)=”a”,f(2)=”b”,f(i)=f(i-1)+f(i-2),”+”表示连接符。给定n,m,求f(n)的前m个字符的“next值”。分析:打表找到第一个i使M+1<|f(i)| ,答案为 m-|f(i-2)| % MOD 高精度 网上找了一个模板。#include <cstdio>#include <iostream>#incl...原创 2018-02-10 19:49:41 · 298 阅读 · 0 评论 -
【hdu 5349 2015多校赛】A simple problem(multiset)
Problem Description You have a multiple set,and now there are three kinds of operations: 1 x : add number x to set 2 : delete the minimum number (if the set is empty now,then ignore it) 3 : qu...原创 2018-02-10 20:25:38 · 365 阅读 · 0 评论 -
【HDU 1811 Rank of Tetris】(拓扑排序判环 + 并查集合并)
自从Lele开发了Rating系统,他的Tetris事业更是如虎添翼,不久他遍把这个游戏推向了全球。为了更好的符合那些爱好者的喜好,Lele又想了一个新点子:他将制作一个全球Tetris高手排行榜,定时更新,名堂要比福布斯富豪榜还响。关于如何排名,这个不用说都知道是根据Rating从高到低来排,如果两个人具有相同的Rating,那就按这几个人的RP从高到低来排。 终于,Lele要开始行动了原创 2018-02-02 16:36:06 · 311 阅读 · 0 评论 -
【hdu 2647 Reward 】(拓扑排序判环,构造反向图)
题意:老板给n个人发工资,有m中关系(a比b多),每个人至少888元,问老板至少准备多少钱,如果存在环输出-1。分析:知道了最少888元,最多的不知道,构造反向图即可,用拓扑排序判环代码:#include #include #include #include #include #include #include #include #include #include原创 2018-02-02 13:37:45 · 378 阅读 · 0 评论 -
【hdu 2412 Party at Hali-Bula 】(树形dp求最大独立集+判断唯一性)
链接:https://vjudge.net/contest/204190#problem/B 题意:给定一棵关系树 , 从中选择一些点 , 使这些点均不存在亲子关系 , 最多能取多少个点 , 并且判断取法是否唯一 .分析: 树形dp 首先一次dfs 求出最大独立集 用boss[i]存储编号i 的上司。 假设上司i的下属为j 如果最大独立集不唯一时,必定有dp[i][0] > dp[原创 2018-01-30 19:41:10 · 307 阅读 · 0 评论 -
广东工业大学2017新生赛(决赛)-网络同步赛
蒻苣的题解…… 1001.junior97与The Flash 用余弦定理求正n边形中心到顶点的距离。 1002.狗哥的肚子 取三者中面积的最大值1003.没有题目背景的水题 利用前缀和或者尺取法1004.Gakki的疑问 贪心1005.Joefery大佬的考核 相似得出a*b%100071006.算法的魅力 利用容斥原理和等差数列和1007.白色相簿的季节 错排公式 ans[1]原创 2017-12-10 01:29:15 · 755 阅读 · 0 评论 -
母函数
定义:对于序列a0,a1,a2,…构造一函数:G(x)=a0+a1*x+a2*x^2+a3*x^3+……, 称函数G(x)是序列a0,a1,a2,…的母函数。参考:http://www.wutianqi.com/?p=596hdu 1028(母函数 模板) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1028#include <cstdio>#i原创 2017-12-12 08:37:07 · 336 阅读 · 0 评论 -
(hdu1085)Holding Bin-Laden Captive!(母函数,打表)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1085 题意:分别给num1,num2,num3个1元,2元,5元硬币,求不能凑出来的最小值分析:母函数 也是打表#include <cstdio>#include <cmath>#include <cstring>#include <iostream>#include <string>#in原创 2017-12-12 09:00:04 · 286 阅读 · 0 评论 -
(hdu1874)畅通工程续(dijkstra算法)
Problem Description某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。Input本题目包含多组数据,请处理到文件结束。 每组数据第一行包含两个正整数N和M(0<N<原创 2017-07-22 09:43:11 · 771 阅读 · 0 评论 -
(hdu4059)The Boss on Mars(费马小定理+快速幂)
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2797 Accepted Submission(s): 894Problem Description On Mars, there is a huge company called原创 2017-08-02 19:42:26 · 374 阅读 · 0 评论 -
还是畅通工程(最小生成树模板题)
http://acm.hdu.edu.cn/webcontest/contest_showproblem.php?cid=11670&pid=1007&ojid=0思路:按村庄间的距离从小到大排序,选择构成最小生成树1.prim算法本题的数据村庄(即顶点的个数)不是很大,故可直接遍历,若数据很大时,就需要用堆来维护每个顶点的当前最短距离265 MS1608 KB原创 2017-06-01 11:40:17 · 467 阅读 · 0 评论 -
Lake Counting(搜索之DFS)
查看题目点击:http://poj.org/problem?id=2386思路:先找到一个为'W'的点,然后对其周围的8个方向搜索,每次搜索ans++#includeusing namespace std;const int N=105;int n,m,num;char a[N][N];void dfs(int x,int y){ a[x][y]='.原创 2017-06-19 22:35:50 · 388 阅读 · 0 评论 -
Oil Deposits
Problem DescriptionThe GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates原创 2017-07-09 15:59:24 · 336 阅读 · 0 评论 -
Knight Moves(BFS模板)
Problem DescriptionA friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of原创 2017-07-15 17:31:25 · 486 阅读 · 0 评论 -
rescue(BFS+优先队列)
Problem Description Angel was caught by the MOLIGPY! He was put in prison by Moligpy. The prison is described as a N * M (N, M <= 200) matrix. There are WALLs, ROADs, and GUARDs in the prison.Angel’原创 2017-07-18 23:40:25 · 374 阅读 · 0 评论 -
Sum It Up(DFS)
Problem Description Given a specified total t and a list of n integers, find all distinct sums using numbers from the list that add up to t. For example, if t = 4, n = 6, and the list is [4, 3, 2, 2,原创 2017-07-19 23:31:48 · 302 阅读 · 0 评论 -
Prime Ring Problem(经典回溯法)
Problem Description A ring is compose of n circles as shown in diagram. Put natural number 1, 2, …, n into each circle separately, and the sum of numbers in two adjacent circles should be a prime.Note原创 2017-07-20 19:41:34 · 2778 阅读 · 2 评论 -
(hdu1420)Prepared for New Acmer(快速幂运算模板)
集训进行了将近2个礼拜,这段时间以恢复性训练为主,我一直在密切关注大家的训练情况,目前为止,对大家的表现相当满意,首先是绝大部分队员的训练积极性很高,其次,都很遵守集训纪律,最后,老队员也起到了很好的带头作用,这里特别感谢为这次DP专题练习赛提供题目和测试数据的集训队队长xhd同学. 特别高兴的是,跟随集训队训练的一批新队员表现非常好,进步也比较显著,特别是训练态度大大超出我的预期,我敢说,如果各位原创 2017-07-30 12:41:37 · 386 阅读 · 0 评论 -
(hdu1257)最少拦截系统(DP)
ime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 43418 Accepted Submission(s): 16928Problem Description 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有原创 2017-07-30 10:47:43 · 325 阅读 · 0 评论 -
(hdu2084)数塔(DP)
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 45418 Accepted Submission(s): 26965Problem Description 在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:有如下原创 2017-07-30 10:22:55 · 371 阅读 · 0 评论 -
逃离迷宫(BFS)
Problem Description 给定一个m × n (m行, n列)的迷宫,迷宫中有两个位置,gloria想从迷宫的一个位置走到另外一个位置,当然迷宫中有些地方是空地,gloria可以穿越,有些地方是障碍,她必须绕行,从迷宫的一个位置,只能走到与它相邻的4个位置中,当然在行走过程中,gloria不能走到迷宫外面去。令人头痛的是,gloria是个没什么方向感的人,因此,她在行走过程中,不原创 2017-07-20 19:52:17 · 635 阅读 · 0 评论 -
Zipper(DFS,DP)
Problem Description Given three strings, you are to determine whether the third string can be formed by combining the characters in the first two strings. The first two strings can be mixed arbitraril原创 2017-07-20 19:11:10 · 375 阅读 · 0 评论 -
(sgu-344)Weed
Problem DescriptionAndrew has visited his garden for the last time many years ago. Today’s property taxes are so high, so Andrew decided to sell his garden. The land was not cultivated for a long time原创 2017-07-20 10:20:11 · 397 阅读 · 0 评论 -
(hdu 1579)Function Run Fun (记忆化搜索)
We all love recursion! Don’t we? Consider a three-parameter recursive function w(a, b, c): if a <= 0 or b <= 0 or c <= 0, then w(a, b, c) returns: 1 if a > 20 or b > 20 or c > 20, then w(a, b, c) r原创 2017-08-19 12:18:48 · 376 阅读 · 0 评论 -
(hdu 1698) Just a Hook(区间更新)
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 34260 Accepted Submission(s): 16716Problem Description In the game of DotA, Pudge’s meat ho原创 2017-08-10 11:27:25 · 432 阅读 · 0 评论