Multi-Univ
ffutop
这个作者很懒,什么都没留下…
展开
-
2017 Multi-University Training Contest 1 (9/12)
1001 - Add More Zero题:在 [0, 2m−1][0,\ 2^m-1] 求最大的 k ,使得满足 0≤10k≤2m−10 \le 10^k \le 2^m-1 。限制:1≤m≤1051\le m\le 10^5解:10k≤2m−110^k \le 2^m-1 等价于 10k≤2m10^k \le 2^m ,求 k=⌊log102m⌋k = \lfloor \log_{10}{2^m原创 2017-07-27 09:06:43 · 485 阅读 · 0 评论 -
HDU 6069 Counting Divisors (2017 Multi-Univ Training Contest 4)
Problem定义 d(n) 表示数字 n 的约数个数给定 l, r, k, 求 (∑ri=ld(ik))mod998244353(\sum_{i=l}^{r}{d(i^k)}) \mod{998244353}Limit1≤l≤r≤10121\le l \le r \le10^{12}1≤k≤1071 \le k \le 10^7Idean=ap11⋅ap22⋯apiin = a_1^{p_1}\c原创 2017-08-04 10:04:56 · 394 阅读 · 0 评论 -
HDU 6070 Dirt Ratio (二分+线段树, 2017 Multi-Univ Training Contest 4)
ProblemN 长区间每个数为 aia_i,任取一段区间,定义 X 表示所取区间不相同数个数,Y 表示所取区间长度,求最小 XY\frac{X}{Y} 。Limit1≤n≤600001\le n \le 600001≤ai≤n1\le a_i\le nIdea感觉比赛时候各种乱来。挂机 4 小时想不出这题的正解…对答案进行二分枚举(:cry: 很显然有二分性,我竟然一开始就否定了)。对每次二分的答原创 2017-08-04 10:06:45 · 412 阅读 · 0 评论 -
HDU 6073 Matching In Multiplication (拓扑+DFS, 2017 Multi-Univ Training Contest 4)
ProblemIn the mathematical discipline of graph theory, a bipartite graph is a graph whose vertices can be divided into two disjoint sets U and V (that is, U and V are each independent sets) such that e原创 2017-08-04 15:08:37 · 940 阅读 · 3 评论 -
HDU 6072 Logical Chain (Biset+Kosaraju, 2017 Multi-Univ Training Contest 4)
ProblemEvery time you come across a problem you’ve never seen before, haven’t you thought of something that is familiar to you? If so, you might think of something else, then more and more things will原创 2017-08-11 16:35:35 · 669 阅读 · 0 评论 -
HDU 6046 hash (HASH, 2017 Multi-Univ Training Contest 2)
Problem106×10610^6 \times 10^6 的 01 矩阵(记作 A )根据下列提供函数给定,f(x, y) 表示该矩阵的 x 行 j 列的数inline unsigned sfr(unsigned h, unsigned x) { return h >> x;}int f(LL i, LL j) { LL w = i * 1000000ll + j; int h原创 2017-08-05 07:44:45 · 568 阅读 · 0 评论 -
HDU 6074 Phone Call (LCA+并查集, 2017 Multi-Univ Training Contest 4)
ProblemThere are n houses in Bytetown, labeled by 1,2,…,n. In each house, there is a person living here. Little Q lives in house 1. There are n−1 bidirectional streets connecting these houses, forming原创 2017-08-05 14:36:45 · 1246 阅读 · 0 评论 -
HDU 6136 Death Podracing (2017 Multi-Univ Training Contest 8)
ProblemProblem LinkIdea解题的必要前提:将剩余的所有人按照初始位置从小到大排序,重新依次编号 1 ~ n 。则显然,最早的两人相遇一定发生在某两个编号相邻的人之间(1 与 n 也视作相邻)。故用 set 维护剩余的人的编号,当某个编号为 i 的人被淘汰后,在 set 中删除编号 i ,同时查找与 i 左相邻及右相邻的两个编号,显然此时这两个编号也又可能是在淘汰 i 之后,最快相原创 2017-08-20 10:11:44 · 472 阅读 · 0 评论 -
HDU 6086 Rikka with String (AC 自动机+状压 dp, 2017 Multi-Univ Training Contest 5)
ProblemAs we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:Yuta has n 01 strings si, and he wants to know the n原创 2017-08-13 10:24:16 · 944 阅读 · 0 评论 -
HDU 6076 Security Check (DP, 2017 Multi-Univ Training Contest 4)
Problem两列队伍,每队 N 人,A 队每人 rank 为 aia_i ,B 队每人 rank 为 bib_i,要求从队首向队尾顺次检查(完成检查的即离队),每次检查可以是下列两种操作的任一种:任选一个队伍的队首检查(如果该队非空)如果两队队首 ∣ai−bi∣>K\mid a_i-b_i\mid \gt K ,则可以同时检查两队队首。Limit1≤N≤600001\le N\le 6000原创 2017-08-06 11:11:13 · 662 阅读 · 0 评论 -
HDU 6093 Rikka with Number (2017 Multi-Univ Training Contest 5)
Problemd (d≥2d\ge2)进制下的 好数 被定义为:K=(A1A2...Ad)d(A_1A_2...A_{d})_d , 其中 Ai≠AjA_i\ne A_j 且 0≤Ai≤d−10\le A_i\le d-1 ,同时 A1≠0A_1 \ne 0求区间 [L,R][L, R] 中多少数恰好是 d 进制下的好数 ?Limit1≤L≤R≤1050001\le L \le R \le 10^{原创 2017-08-14 14:56:22 · 513 阅读 · 0 评论 -
HDU 6096 String (字典树, 2017 Multi-Univ Training Contest 6)
Problem有 N 组单词 WiW_i ,以及 Q 组前缀 PiP_i ,后缀 SiS_i 。求对于每组前后缀,能匹配多少单词。Idea利用字典树解决。将前缀与后缀拼接形成 任意拼接符Pi+任意拼接符+reverse(Si)任意拼接符P_i + \text{任意拼接符} + reverse(S_i) 。并离线将全部询问加入字典树中,在最后一个节点位置标记上该点标号。枚举每个单词,查找单词在字典树上原创 2017-08-14 16:24:00 · 492 阅读 · 0 评论 -
HDU 6124 Euler theorem (2017 Multi-Univ Training Contest 7)
ProblemHazelFan is given two positive integers a,b, and he wants to calculate a mod b. But now he forgets the value of b and only remember the value of a, please tell him the number of different possib原创 2017-08-15 21:11:59 · 402 阅读 · 0 评论 -
HDU 6078 Wavel Sequence (dp + 树状数组, 2017 Multi-Univ Training Contest 4)
Problem含 N 个数的 a 数组 a1,a2,⋯,ana_1, a_2,\cdots, a_n 和含 M 个数的 b 数组 b1,b2,⋯,bmb_1, b_2,\cdots, b_m ,求有多少 a,b 公共子序列(记作 arr, 长为 len )满足 arr1<arr2>arr3<arr4>arr5⋯arr_1 \lt arr_2\gt arr_3\lt arr_4 \gt arr_5\c原创 2017-08-04 10:02:29 · 674 阅读 · 0 评论 -
HDU 6071 Lazy Running (Dijstra, 2017 Multi-Univ Training Contest 4)
Problem四个打卡点 p1,p2,p3,p4p_1, p_2,p_3,p_4 。已知 d1,2,d2,3,d3,1,d1,4d_{1,2}, d_{2,3}, d_{3,1}, d_{1,4} 的距离(可双向连通),其它任意两点间均无直接路径。求从 2 出发,任意通过路径回到 2 号点使得总距离恰好 ≥K\ge K 的最小距离是多少?Limit1≤K≤10181\le K \le 10^{18}原创 2017-08-04 10:00:43 · 473 阅读 · 0 评论 -
HDU 6143 Killer Names (容斥, 2017 Multi-Univ Training Contest 8)
Problem要求构造若干名字,名字包括 first name last name 两部分,均需包含 n 个字符,已知有 m 种字符供选择,求最多有多少种不同的构造方法,使得 first name 和 last name 不含相同字符。Idea容斥。枚举 first name 用到的字符为 i 个,则 last name 用到的为 m-i 个 ,此时的方案数为 Cimni×nm−iC原创 2017-08-17 18:41:28 · 548 阅读 · 4 评论 -
2017 Multi-University Training Contest 2
1001 - Is Derek lying?ProblemN 个问题,每个问题只有 A, B, C 三种选项。已知 Derek 和 Alfia 对每题的回答以及对应的最终得分(每题答对 1 分,错误 0 分)。问最终两人的得分是否一定错误。Idea根据两人的回答统计回答相同的题数 same 和不同的题数 diff 。记两人的得分分别为 x 和 y 。得分和 - same > N ,一定说谎。x原创 2017-07-30 09:43:46 · 444 阅读 · 0 评论 -
HDU 6121 Build a tree (递归+特判, 2017 Multi-Univ Training Contest 7)
ProblemProblem LinkHazelFan wants to build a rooted tree. The tree has n nodes labeled 0 to n−1, and the father of the node labeled i is the node labeled⌊i−1k⌋\lfloor \frac{i-1}{k} \rfloor . HazelFan w原创 2017-08-16 10:13:07 · 367 阅读 · 0 评论 -
HDU 6058 Kanade's sum (链表, 2017 Multi-Univ Training Contest 3)
Problem对于 1~n n 个数字的一种任意排序,定义 f(l,r,k) 表示区间 [l, r] 中第 K 大的数(当区间不足 K 个数时,f(l,r,k)=0 )。求 ∑nl=1∑nr=lf(l,r,k)\sum_{l=1}^n\sum_{r=l}^n f(l,r,k) 。Limit1≤T≤101\le T \le 10k≤min(n,80)k\le \min{(n, 80)}∑n≤5⋅105原创 2017-08-02 09:12:04 · 731 阅读 · 0 评论 -
HDU 6059 Kanade's trio (字典树, 2017 Multi-Univ Training Contest 3)
Problem含 N 个数字的 A 数组,求有多少个三元组 (i,j,k) 满足 i<j<ki\lt j\lt k 且 (Ai⊕Aj)<(Aj⊕Ak)(A_i \oplus A_j) < (A_j\oplus A_k)Limit1≤T≤201\le T \le 201≤∑n≤5×1051\le \sum n\le 5\times 10^50≤Ai≤2300\le A_i\le 2^{30}Idea利原创 2017-08-02 09:39:16 · 2022 阅读 · 14 评论 -
HDU 6127 Hard challenge (极角排序+二分, 2017 Multi-Univ Training Contest 7)
ProblemProblem LinkThere are n points on the plane, and the ith points has a value valival_i, and its coordinate is (xi,yix_i,y_i). It is guaranteed that no two points have the same coordinate, and no原创 2017-08-15 20:45:58 · 591 阅读 · 2 评论 -
HDU 6125 Free from square (状压 dp , 2017 Multi-Univ Training Contest 7)
ProblemProblem Link有 [1,n][1, n] 的所有正整数,求最少取 1 个,最多取 k 个,使得所取数的累积 ∏xi\prod{x_i} 不能被某个数的平方整除。问有多少种取值方案。Idea显然,根据题意得到所得数的累积 ∏xi\prod{x_i} 对于每种素数只能取到 1 次。故如果能够状压下所有的素数状态,就是简单的状压 dp 。当然,事实上根本不可能,素数过多。考虑,对于原创 2017-08-16 14:45:30 · 446 阅读 · 0 评论 -
HDU 6085 Rikka with Candies (bitset, 2017 Multi-Univ Training Contest 5)
ProblemProblem LinkAs we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:There are n children and m kinds of cand原创 2017-08-09 13:42:57 · 574 阅读 · 0 评论 -
HDU 6090 Rikka with Graph (贪心+构造, 2017 Multi-Univ Training Contest 5)
Problem图上两点间距离被定义为 disti,jdist_{i,j} 为两点间最短路距离(任意直接相连两点距离为 1 ),若两点不连通,则记 disti,jdist_{i,j} 为该图中点数 n 。要求构造一个 n 点 m 条边的图 G ,使得 ∑ni=1∑nj=1disti,j\sum_{i=1}^n\sum_{j=1}^n dist_{i,j} 最小。Limit1≤n≤1061\le n\原创 2017-08-09 13:54:06 · 481 阅读 · 0 评论 -
HDU 6065 RXD, tree and sequence (LCA, 2017 Multi-Univ Training Contest 3)
Problem有根树 T 有 N 个节点,根节点标号为 1 ,深度为 1 。特定序列 P 有 N 个不同数字 (1~N) 。定义每个块的深度为块中所有点的最近公共祖先的深度。求将 P 序列划分成 K 个连续的块,使得 K 块的深度和最小,问最小深度和 ?Limit1≤k≤n≤3×1051\le k \le n \le 3\times 10^5n×k≤3×105n\times k \le 3\time原创 2017-08-02 17:05:13 · 577 阅读 · 0 评论 -
HDU 6140 Hybrid Crystals (2017 Multi-Univ Training Contest 8)
ProblemProblem Link不想翻译,估计尝试但没过的都只读了最后一段。(友好的) 出题人挖了好大一个坑,重点限制条件不在最后一段。Idea只看最后一段,此题为 NP 问题,但是,之前的额外条件可以将此题视作贪心。由于给出的数是有限制的,故 [1, i] 线性扫描,必然能够取得 [l, r] 区间的所有数(l , r 表示分别表示前 i 个数任取得到的最小数和最大数,不要问为什么,读完全原创 2017-08-17 19:40:41 · 376 阅读 · 0 评论 -
HDU 6138 Fleet of the Eternal Throne (后缀数组+字典树, 2017 Multi-Univ Training Contest 8)
Problemn 行字符串(只含有小写字母)。m 组询问,每组询问给定 x, y ,求第 x 行与第 y 行字符串的最长公共子序列长度(当然,需要额外满足,取得的字符串必须是某行的前缀)。Idea貌似想复杂了,后缀数组+字典树过的。官方题解表示用 AC 自动机。预处理维护一棵字典树,用于判断获得的公共子序列是否是某串的前缀,或该公共子序列的某个前缀是否是某串的前缀(不过多介绍)。对于每次询问,将第原创 2017-08-17 19:57:08 · 890 阅读 · 0 评论 -
HDU 6128 Inverse of sum (数论, 2017 Multi-Univ Training Contest 7)
ProblemThere are n nonnegative integers a1…n which are less than p. HazelFan wants to know how many pairs i,j(1≤iIdea⟺⟺⟺1ai+aj≡1ai+1aj1ai+aj≡ai+ajai⋅ajai⋅aj≡(ai+aj)2a2i+ai⋅aj+a2j≡0modpmodpmodpmodp(1)(2原创 2017-08-17 20:36:29 · 687 阅读 · 0 评论 -
HDU 6133 Army Formations (树状数组, 2017 Multi-Univ Training Contest 8)
ProblemProblem LinkThough being cruel and merciless in the battlefields, the total obedience to the command hierarchy makes message delivering between Stormtroopers quite inefficient, which finally cau原创 2017-08-21 10:59:40 · 435 阅读 · 0 评论