摘要: 比赛总结 分数:100+100+48+30 个人认为,T2乱搞竟然是正解,而T3看到 \(10^7\) 就一直在想 \(O(n)\) 做法,但其实打 \(O(n\log n)\) 就行了。 而当时我在赛场上懒得打 \(O(n\log n)\),就随便糊了一个 \(O(n\sqrt n)\) 的做法上 阅读全文
posted @ 2022-01-10 08:51 zhangtingxi 阅读(48) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 定义$f(n) = |n - \sum_{d|n,d\not =n}d|$。 每次给出$A,B$,求$\sum_{i=A}^B f(i)$。 对于$100%$的数据,\(A,B\le 10^7\)。 思路 看到 \(A,B\) 的范围,想着能不能快速求 \(f(n)\)。 难点就在于 阅读全文
posted @ 2022-01-09 11:04 zhangtingxi 阅读(45) 评论(0) 推荐(0) 编辑
摘要: 成绩: (惨败) A题,写成一个函数,题目怎么说就怎么做。 B题,直接 \(O(n^2)\) 枚举,调了好久,最后发现是欧式距离写错了。于是我得到了经验,欧式距离不能再记错了(\(dis=\sqrt{(x_i-x_j)^2+(y_i-y_j)^2}\))。 C题一看,拿出计算器算了一下前几个样例,发 阅读全文
posted @ 2022-01-09 10:35 zhangtingxi 阅读(449) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 给定两个长度为 \(n\) 的只包含'a','b','c'的字符串$s,t$。 请打乱串 \(s\),使得 \(\forall i,s_i \not= t_i\),且 \(s\) 字典序最小。 思路 对于 \(t\) 串中从前往后每一个字母,在 \(s\) 的剩余可选字母中选字典序最 阅读全文
posted @ 2022-01-08 16:16 zhangtingxi 阅读(50) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 给定一个数字 \(N\),请问有哪些区间 \([L,R]\) 使得 \(\sum_{i=L}^R i=N\)。 请按 \(L\) 从小到大的顺序输出所有区间。 思路 根据题意我们可以列出方程: \(\frac{(L+R)(R-L+1)}{2}=n\) 也就是: \((L+R)(R-L 阅读全文
posted @ 2022-01-08 15:44 zhangtingxi 阅读(40) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 一年一度的展会要来临了,Farmer John 想要把 \(N\)(\(1 \leq N \leq 100,000\))只奶牛和公牛安排在单独的一行中。 John 发现最近公牛们非常好斗;假如两只公牛在这一行中靠的太近,他们就会吵架,以至于斗殴,破坏这和谐的环境。 John 非常的足 阅读全文
posted @ 2022-01-07 14:22 zhangtingxi 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 给定一个多项式 \((by+ax)^k\),请求出多项式展开后 \(x^n\times y^m\) 项的系数。 思路 根据二项式定理 \((a+b)^k=\sum_{i=0}^kC_{k}^ia^ib^{k-i}\) 我们可以把原式变为: \((ax+by)^k=\sum_{i=0} 阅读全文
posted @ 2022-01-07 11:53 zhangtingxi 阅读(135) 评论(0) 推荐(0) 编辑
摘要: GDKOI前我的算法复习情况: 好了,GDKOI死了。 这个是根据一本通提高篇章节制定的。 练习 剩余题量 备注 练习 剩余题量 备注 练习 剩余题量 备注 练习 剩余题量 备注 贪心算法 已完成 区间DP 1 质数 5 同余 8 二分三分 已完成 RMQ 1 我做出的两题都不是用平衡树 状压dp 阅读全文
posted @ 2021-12-25 19:54 zhangtingxi 阅读(104) 评论(0) 推荐(1) 编辑
摘要: 丽泽普及2022交流赛day1总结 提交情况 8:52 T1 9:19 T3 9:26 T4 9:28 T4 10:32 T2 10:49 T1 A. Efim与奇怪的成绩 题目 众所周知,每当我们看见自己糟糕的成绩时,我们总希望以奇怪的方式将其四舍五入。 Efim同样如此。在晴朗的一天,Efim拿 阅读全文
posted @ 2021-12-25 12:51 zhangtingxi 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make 阅读全文
posted @ 2021-12-24 19:02 zhangtingxi 阅读(83) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 This is yet another problem on regular bracket sequences. A bracket sequence is called regular, if by inserting "+" and "1" into it we get a c 阅读全文
posted @ 2021-12-24 18:32 zhangtingxi 阅读(57) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 Certainly, everyone is familiar with tic-tac-toe game. The rules are very simple indeed. Two players take turns marking the cells in a 3 × 3 g 阅读全文
posted @ 2021-12-23 18:49 zhangtingxi 阅读(71) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 古埃及,人们使用单位分数的和(形如 \(\dfrac{1}{a}\) 的,\(a\) 是自然数)表示一切有理数。如:\(\dfrac{2}{3} = \dfrac{1}{2} + \dfrac{1}{6}\),但不允许 \(\dfrac{2}{3} = \dfrac{1}{3} + 阅读全文
posted @ 2021-12-23 18:24 zhangtingxi 阅读(355) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 A group of tourists is going to kayak and catamaran tour. A rented lorry has arrived to the boat depot to take kayaks and catamarans to the po 阅读全文
posted @ 2021-12-22 18:32 zhangtingxi 阅读(79) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 There is a square matrix n × n, consisting of non-negative integer numbers. You should find such a way on it that starts in the upper left cel 阅读全文
posted @ 2021-12-22 17:24 zhangtingxi 阅读(43) 评论(0) 推荐(0) 编辑
摘要: T1 Closest Cow Wins 题目 Farmer John owns a long farm along the highway that can be considered somewhat like a one-dimensional number line. Along the fa 阅读全文
posted @ 2021-12-21 18:38 zhangtingxi 阅读(621) 评论(0) 推荐(0) 编辑
摘要: 题目 The cows are hard at work trying to invent interesting new games to play. One of their current endeavors involves a set of \(N\) intervals (\(1\le 阅读全文
posted @ 2021-12-21 18:35 zhangtingxi 阅读(395) 评论(0) 推荐(0) 编辑
摘要: 题目 Farmer John's farm consists of a set of \(N\) fields \((1 \leq N \leq 10^5)\), conveniently numbered \(1 \ldots N\). Between these fields are \(M\) 阅读全文
posted @ 2021-12-21 18:25 zhangtingxi 阅读(428) 评论(0) 推荐(0) 编辑
摘要: 题目 Farmer John owns a long farm along the highway that can be considered somewhat like a one-dimensional number line. Along the farm, there are \(K\) 阅读全文
posted @ 2021-12-21 18:10 zhangtingxi 阅读(524) 评论(0) 推荐(0) 编辑
摘要: T1 Lonely Photo 题目 Farmer John has recently acquired N new cows (3≤N≤5×105), each of whose breed is either Guernsey or Holstein. The cows are currentl 阅读全文
posted @ 2021-12-21 17:54 zhangtingxi 阅读(938) 评论(0) 推荐(0) 编辑
摘要: 题目 Bessie the cow is trying to walk from her favorite pasture back to her barn. The pasture and farm are on an N×N grid (2≤N≤50 ), with her pasture in 阅读全文
posted @ 2021-12-21 17:51 zhangtingxi 阅读(607) 评论(2) 推荐(0) 编辑
摘要: 题目 Farmer John's cows N are very particular about the room temperature in their barn. Some cows like the temperature to be on the cooler side, while o 阅读全文
posted @ 2021-12-21 17:40 zhangtingxi 阅读(587) 评论(0) 推荐(0) 编辑
摘要: 题目 Farmer John has recently acquired N new cows (3≤N≤5×105), each of whose breed is either Guernsey or Holstein. The cows are currently standing in a 阅读全文
posted @ 2021-12-21 17:33 zhangtingxi 阅读(719) 评论(2) 推荐(0) 编辑
摘要: 题目链接 题目 The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is 阅读全文
posted @ 2021-12-20 18:50 zhangtingxi 阅读(72) 评论(0) 推荐(0) 编辑
摘要: 二分 对于一个存在单调性的函数,我们要枚举满足条件的最小/最大值,我们通过枚举中间值缩小范围来定位。 while(l<r) { mid=(l+r+1)>>1; if(check(mid)) l=mid; else r=mid-1; } 三分 对于一个存在单峰/单谷性的函数,我们可以通过枚举两个端点通 阅读全文
posted @ 2021-12-18 10:08 zhangtingxi 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 将整数 \(n\) 分成 \(k\) 份,且每份不能为空,任意两个方案不相同(不考虑顺序)。 例如:\(n=7\),\(k=3\),下面三种分法被认为是相同的。 \(1,1,5\); \(1,5,1\); \(5,1,1\). 问有多少种不同的分法。 思路 首先我们可以打出一个暴力。 阅读全文
posted @ 2021-12-18 09:44 zhangtingxi 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 有 \(N+M\) 个问题,其中有 \(N\) 个问题的答案是 YES,\(M\) 个问题的答案是 NO。当你回答一个问题之后,会知道这个问题的答案,求最优策略下期望对多少。 答案对 \(998244353\) 取模。 思路 首先假设撇开算期望,就一个贪心,如果 \(n>m\),我们 阅读全文
posted @ 2021-12-16 18:39 zhangtingxi 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 Snuke is having another barbeque party. This time, he will make one serving of Skewer Meal. He has a stock of N Skewer Meal Packs. The i-th Sk 阅读全文
posted @ 2021-12-15 18:46 zhangtingxi 阅读(57) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 在一个 \(2\) 维平面上有两条传送带,每一条传送带可以看成是一条线段。两条传送带分别为线段 \(\text{AB}\) 和线段 \(\text{CD}\)。lxhgww 在 \(\text{AB}\) 上的移动速度为 \(P\),在 \(\text{CD}\) 上的移动速度为 \ 阅读全文
posted @ 2021-12-15 17:38 zhangtingxi 阅读(73) 评论(0) 推荐(0) 编辑
摘要: 组合数学的推式子题公式基本上都有了 \(\Large\sum_{i=0}^nC_n^i=2^n\) \(\Large\sum_{i=0}^nC_n^i(-1)^i=0\) \(\Large\sum_{i=0}^nC_n^ix^i=(1+x)^n\) \(\Large C_n^kC_k^i=C_n^i 阅读全文
posted @ 2021-12-14 22:03 zhangtingxi 阅读(349) 评论(0) 推荐(0) 编辑
摘要: 题目链接 由于BZOJ已挂,这里是黑暗爆炸和hydro的备份 黑暗爆炸: 国王奇遇记 国王奇遇记加强版 hydro: 国王奇遇记 国王奇遇记加强版 题目 Katharon 国有着悠久的历史,每个慕名而来的游客都渴望能在 Katharon 国发现一些奇怪的宝藏。而作为国王的 Kanari 君也梦想着有 阅读全文
posted @ 2021-12-14 18:44 zhangtingxi 阅读(147) 评论(0) 推荐(0) 编辑
摘要: \(\Large(a+b)^n=\sum_{k=0}^n C_n^ka^kb^{n-k}\) 在化简一些式子时有用 因此,\(2^n\) (也就是当 \(a=b=1\) )时也可以表示为: \(\Large2^n=\sum_{k=0}^n C_n^ka^kb^{n-k}\) 然而后面这个公式我也不知 阅读全文
posted @ 2021-12-14 17:23 zhangtingxi 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 求: $$\Large\begin{cases}S\equiv b_1\pmod {a_1}\ S\equiv b_2\pmod {a_2}\ \cdots\ S\equiv b_i\pmod {a_i}\ \cdots\ S\equiv b_n\pmod {a_n}\ \end{cases}$$ 阅读全文
posted @ 2021-12-13 22:05 zhangtingxi 阅读(37) 评论(0) 推荐(0) 编辑
摘要: 前言 拓欧总是记不住,总是想不懂,希望写篇博客加深影响。 拓展欧几里得定理推论 求: \(\Large ax+by=\gcd(a,b)\) 的其中一组整数解 \(x,y\)。 首先可以证明必有解(留坑) 按照欧几里得定理:\(\gcd(a,b)=\gcd(b,a\%b)\) \(\Large k_1 阅读全文
posted @ 2021-12-13 21:20 zhangtingxi 阅读(25) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 相比 \(Wildleopard\) 的家,他的弟弟 \(Mildleopard\) 比较穷。他的房子是狭窄的,而且在他的房间里仅有一个灯泡。每天晚上,他徘徊在自己狭小的房子里,思考如何赚更多的钱。有一天,他发现他的影子的长度随着他在灯泡和墙壁之间走动时会发生变化。一个突然的想法出现 阅读全文
posted @ 2021-12-11 15:22 zhangtingxi 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 一个点每过一个单位时间就会向四个方向扩散一个距离,如图。 两个点a、b连通,记作e(a,b),当且仅当a、b的扩散区域有公共部分。连通块的定义是块内的任意两个点u、v都必定存在路径e(u,a0),e(a0,a1),…,e(ak,v)。给定平面上的n给点,问最早什么时刻它们形成一个连通 阅读全文
posted @ 2021-12-11 10:32 zhangtingxi 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 对于给定的一个长度为N的正整数数列 \(A_{1\sim N}\),现要将其分成 \(M\)(\(M\leq N\))段,并要求每段连续,且每段和的最大值最小。 关于最大值最小: 例如一数列 \(4\ 2\ 4\ 5\ 1\) 要分成 \(3\) 段。 将其如下分段: \([4\ 2 阅读全文
posted @ 2021-12-11 10:11 zhangtingxi 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 明明做作业的时候遇到了 nnn 个二次函数 Si(x)=ax2+bx+cS_i(x)= ax^2 + bx + cS​i​​(x)=ax​2​​+bx+c,他突发奇想设计了一个新的函数 F(x)=max{Si(x)},i=1…nF(x) = max{S_i(x)}, i = 1ldo 阅读全文
posted @ 2021-12-11 10:03 zhangtingxi 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 给定长度为 n 的数列 a,如果 (按位与),则在 i,j 之间存在一条长度为 的边,求 1 至所有点的最短路。 思路 暴力连边,边太多,最多 \(n^2\) 条,MLE+TLE。 于是考虑减少边的数量。 首先建32个虚点。 然后加入 \(a_i\) 在第 \(k\) 位上为1,就在 阅读全文
posted @ 2021-12-10 18:59 zhangtingxi 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 题目链接 题目 给定一个长度为 nnn 的非负整数序列 AAA ,求一个平均数最大的,长度不小于 LLL 的子段。 思路 先二分平均值。 然后是判断。 如何判断一段数中是否存在长度大于等于 \(L\) 且平均值大于某个数的子段呢? 我们可以先让序列中的数都减去二分中的值,然后就转化为: 序列中是否存 阅读全文
posted @ 2021-12-09 22:37 zhangtingxi 阅读(190) 评论(0) 推荐(0) 编辑