08 2019 档案
摘要:struct MCMF { struct edge { int to, cap, cost, rev; //edge() {} //edge(int to, int _cap, int _cost, int _rev) : to(to), cap(_cap), cost(_cost), rev(_rev) {} }; int V, H[maxn + 5], dis[maxn + 5], PreV[
阅读全文
摘要:问题 G: Mad Veterinarian 题目描述 Mad Veterinarian puzzles have a mad veterinarian, who has developed several machines that can transform an animal into one
阅读全文
摘要:【 哈希和哈希表】Three Friends 题目描述 Three friends like to play the following game. The first friend chooses a string S. Then the second friend constructs a ne
阅读全文
摘要:问题 E: Plug It In! 题目描述 Adam just moved into his new apartment and simply placed everything into it at random. This means in particular that he did not
阅读全文
摘要:问题 s: 网格VI 题目描述 某城市的街道呈网格状,左下角坐标为A(0, 0),右上角坐标为B(n, m),其中n >= m。现在从A(0, 0)点出发,只能沿着街道向正右方或者正上方行走,且不能经过图示中直线左上方的点,即任何途径的点(x, y)都要满足x >= y,请问在这些前提下,到达B(n
阅读全文
摘要:问题 J: 【数论】数字迷阵 题目描述 小可可参观科学博物馆时,看到一件藏品,上面有密密麻麻的数字,如下所示: 1 2 3 5 8 13 21 34 55 89 144 ... 4 7 11 18 29 47 76 123 199 322 521 ... 6 10 16 26 42 63 110 1
阅读全文
摘要:【数论】普通递归关系 题目描述 考虑以下定义在非负整数 n 上的递归关系其中 a,b 是满足以下两个条件的常数:(1) a2+4b>0(2) |a-sqrt(a2+4b)| <= 2 // sqrt 是根号的意思给定 f0,f1, a, b 和 n,请你写一个程序计算f(n),可以假定f(n)是绝对
阅读全文
摘要:链式前向星与vector的两种邻接表建图 vector建图简单直观,加边灵活,但占用内存大。 链式前向星建图比较容易操作。 链式前向星 vector
阅读全文
摘要:原题链接http://acm.hdu.edu.cn/showproblem.php?pid=6624 题意求一个最小正整数b,使得 a ≡ bx (mod p) 这里直接放上dls的题解,讲的贼清楚。 然后辗转相除一下,找到出口再把答案递归回去就ok了。 注意的是,b乘x会炸long long
阅读全文
摘要:题目链接http://acm.hdu.edu.cn/showproblem.php?pid=6627 题意是给出n个套上绝对值的一元一次方程,求x使得他们的和等于c。 对于|ax+b|,考虑去掉绝对值,只有两种情况 ax+b 和 -ax-b,取决于x的取值,也就是 x 与 b/a 的大小关系。 然后
阅读全文
摘要:欧几里得算法(gcd) 重新看了一下简单的gcd算法,有了一些更深的理解方式。 概括的说,gcd算法其实就是连续进行带余除法直到余数为零。 举个例子,求(72,30), 我们知道(a+kb,b)=(a,b)=(b,a) 于是,(72,30)=(30*2+12,30)=(30,12)=(12*2+6,
阅读全文