counting atcoder another 259h

AtCoder Grand Contest 036

A - Triangle 考虑 \(x_1,y_1\) 选原点,构造另外两个点。考虑叉积的形式,可以得出: \[x_2y_3+x_3y_2=S \]令 \(x_2=y_3=\lceil \sqrt S\rceil\),令 \(t=S-x_2y_3\),暴力枚举 \(t\) 的因数即可。 #inclu ......
AtCoder Contest Grand 036

AtCoder Grand Contest 035

A - XOR Circle 可以发现,相邻三个数的异或和一定为 \(0\)。如果三个字符已经确定了,那么整个字符串就已经确定为这三个字符构成,且序列唯一。 如果 \(n\bmod 3\ne 0\),显然无解。 如果字符集的大小大于 \(3\),显然无解。 如果字符集的大小等于 \(3\),只有在这 ......
AtCoder Contest Grand 035

AtCoder Grand Contest 034

Kenken Race 可以分成两种情况: 当 \(A\leq B\leq C\leq D\) 时,先让 \(B\) 到 \(D\),在让 \(A\) 到 \(C\); 当 \(A\leq B\leq D\leq C\) 时,判断一下 \(B\to D\) 是否有三个连续的 .。 然后判断一下 \( ......
AtCoder Contest Grand 034

AtCoder Grand Contest 033

A - Darker and Darker 从 # 向外广搜即可。 #include<iostream> #include<cstdio> #include<cstring> #include<queue> using namespace std; const int N=1005; const i ......
AtCoder Contest Grand 033

AtCoder Grand Contest 032

A - Limited Insertion 考虑从后往前做,插数变成了删数。可以发现,我们可以删去的只有 \(a_i=i\) 的数,如果有多个肯定删最后面的是最优的,因为这样影响到的数最少。每次扫一遍找出删什么数即可。 #include<iostream> #include<cstdio> usin ......
AtCoder Contest Grand 032

AtCoder Grand Contest 030

A - Poisonous Cookies 解毒的饼干肯定所有都吃,剩下的算一下最多能吃多少毒饼干就好了。 #include<iostream> #include<cstdio> using namespace std; int A,B,C; int main() { scanf("%d%d%d", ......
AtCoder Contest Grand 030

AtCoder Grand Contest 029

A - Irreversible operation 对于某个 W 的位置,它的贡献即为前面 B 的个数,直接搞就完事了。 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int N=2 ......
AtCoder Contest Grand 029

AtCoder Grand Contest 048

A - atcoder < S 枚举操作完的串 \(s\) 和 atcoder 相同的前缀长度,算出前面的前缀相同的代价加上当前这位大于 atcoder 中对应的那一位的代价即为达到当前状态的代价,取个最小值即可。 #include<iostream> #include<cstdio> #inclu ......
AtCoder Contest Grand 048

AtCoder Grand Contest 047

A - Integer Product 考虑将原来的数全部化为整数,乘上 \(10^9\),那么问题就变成了是否有两个数的乘积是 \(10^{18}\) 的倍数。考虑如果是 \(10^{18}\) 的倍数的话必然是 \(2^{18}\) 和 \(5^{18}\) 的倍数,那么分解出每个数的 \(2, ......
AtCoder Contest Grand 047

AtCoder Grand Contest 046

A - Takahashikun, The Strider 问题就是要你求 \(ax\equiv 0 \pmod{360}\) 中 \(a\) 的最小值。 答案就是 \(a=\frac{360}{\gcd(x,360)}\)。 代码: #include<iostream> #include<cstd ......
AtCoder Contest Grand 046

AtCoder Grand Contest 045

A - Xor Battle 可以发现,从后往前扫,遇到一个 \(1\) 找后面是否有若干个 \(0\) 的位置的 \(a_i\) 与当前位置的异或和相等,用线性基维护一下就好了。 代码: #include<iostream> #include<cstdio> #include<cstring> u ......
AtCoder Contest Grand 045

AtCoder Grand Contest 044

A - Pay to Win 不妨将操作倒过来考虑,问题就变成了每次除以 \(2,3,5\) 或者 \(+1,-1\),令 \(f_n\) 表示将 \(n\) 变成 \(0\) 的最小花费,然后记忆化搜索即可,可以证明复杂度是对的。 代码: #include<iostream> #include<c ......
AtCoder Contest Grand 044

AtCoder Grand Contest 043

A - Range Flip Find Route 可以发现,一条路径的最小操作数等于路径上有多少 # 的块,令 \(f_{i,j}\) 表示到 \((i,j)\) 的最小操作次数,直接 DP 就行了。 注意路径上一个 \(1\) 的块会被算两次,需要除以 \(2\)。 #include<iostr ......
AtCoder Contest Grand 043

Redis可视化工具:Another Redis Desktop Manager

Redis可视化工具:Another Redis Desktop Manager 一、介绍 Another Redis Desktop Manager(简称:RedisDesktopManager或RDM)是一个Redis数据库的可视化管理工具。它是一个跨平台的桌面应用程序,能够让用户更轻松地与Re ......
Redis Another Desktop Manager 工具

CODE FESTIVAL 2017 Elimination Tournament Round 3 F Unicyclic Graph Counting

洛谷传送门 AtCoder 传送门 看到和度数有关的(基环)树计数,可以想到 Prufer 序。 如果要计数一棵树,那么答案就是 \(\binom{n - 2}{d_1 - 1, d_2 - 1, \ldots, d_n - 1}\)。因为度数为 \(d\) 的点在 Prufer 序中恰好出现 \( ......

AtCoder Beginner Contest 318

AtCoder Beginner Contest 318 A - Full Moon (atcoder.jp) 以\(M\)为首项,\(P\)为公差,看\(1 \sim N\)里包含了多少项的个数 #include<bits/stdc++.h> using i64 = long long; usin ......
Beginner AtCoder Contest 318

AtCoder Regular Contest 165

Preface 这场前三题是上周四写的,今天课有点多本来想着把最近两场CF的博客先写下的 但后面发现还有CCLCC的杂谈没写,写完发现由于晚上要上课没时间了,只能先把这场先写一下 A - Sum equals LCM 设\(n=\prod_{i=1}^k p_i^{c_i}\),不难发现令\(A_1 ......
AtCoder Regular Contest 165

PG 故障分析之 select count(*) 产生大量WAL 日志(wal_log_hint)

Hello, 大家好, 今天给大家分享的这个本周发生在生产环境的一个真实的案例。 故障的现象是: 主库短时间内生成了大量的WAL日志,触发了归档archive_command的操作,导致灾备中心的2台standby 机器同步中断。 Standby Log: FATAL: could not rece ......
wal_log_hint 故障 select count 日志

题解 AtCoder Beginner Contest 268 A~H

RobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinC... ......
题解 Beginner AtCoder Contest 268

数字滚动【vue-count-to】

效果 背景 在大屏或者其他需要对数字设置千分位的分隔符(比如:151234数字展示成 151,234)或者 数字在变化时进行滚动的变化。 使用 安装 npm i vue-count-to demo <template> <div class="app"> <h1> 当前数值: <countTo :s ......
vue-count-to 数字 count vue to

CF1857G Counting Graphs

题目链接 考虑每条非树边的取值,显然不能小于等于该边与树边形成的环中的最大值(当然这条非树边也可以不存在),所以每条非树边的取值范围就是 \(S - max(w) + 1\) (\(+1\)的原因是该边可能不存在)。 暴力枚举肯定会超时,考虑优化。 发现 \(kruskal\) 算法获得最小生成树的 ......
Counting Graphs 1857G 1857 CF

一个树状数组求逆序对的进阶 [USACO17JAN] Promotion Counting P

题面就这样,就是在树上求一个逆序对但是我笨笨地求了对于每一个下属有几个上司能力比他低还一遍就写对了,结果发现看错题目了难得一遍过,但是没有完全过 ......
逆序 数组 Promotion Counting USACO

【题解】AtCoder-ABC321

AtCoder-ABC321A 321-like Checker 依题意判断。 提交记录:Submission - AtCoder AtCoder-ABC321B Cutoff 枚举 \(a_n\),依题意模拟即可。 提交记录:Submission - AtCoder AtCoder-ABC321C ......
题解 AtCoder-ABC AtCoder ABC 321

AtCoder Beginner Contest 321

A - 321-like Checker (abc321 A) 题目大意 给定一个数,问从高位到低位,数字是不是递减的。 解题思路 可以以字符串读入,然后依次判断即可。 神奇的代码 #include <bits/stdc++.h> using namespace std; using LL = lo ......
Beginner AtCoder Contest 321

AtCoder Grand Contest 046 E Permutation Cover

洛谷传送门 AtCoder 传送门 若 \(2\min\limits_{i = 1}^m a_i < \max\limits_{i = 1}^n a_i\) 就无解,因为根据排列的性质必然存在 \(yxxxy\) 或两端 \(xxyy\) 的情况,并且若这个条件不满足,就可以构造一组解。 考虑最小化 ......
Permutation AtCoder Contest Grand Cover

AtCoder Beginner Contest 318 ABCDE

AtCoder Beginner Contest 318 A - Full Moon 思路:等差数列求项数 // AC one more times // nndbk #include <bits/stdc++.h> using namespace std; typedef long long ll ......
Beginner AtCoder Contest ABCDE 318

AtCoder Beginner Contest 320 ABCDE

AtCoder Beginner Contest 320 A - Leyland Number 思路:直接快速幂 // AC one more times // nndbk #include <bits/stdc++.h> using namespace std; typedef long long ......
Beginner AtCoder Contest ABCDE 320

AtCoder Beginner Contest 253 E

AtCoder Beginner Contest 253 E - Distance Sequence 思路:前缀和优化DP 要求$ |a[i]-a[i+1]|>=k\( 定于\)dp[i][j]:\(前\)i\(个数以\)j\(结尾的合法序列数列 \) dp[i][j] += dp[i-1][1~( ......
Beginner AtCoder Contest 253

[ABC309Ex] Simple Path Counting Problem

Problem StatementWe have a grid with $N$ rows and $M$ columns. We denote by $(i,j)$ the cell in the $i$-th row from the top and $j$-th column from the ......
Counting Problem Simple Path ABC

Atcoder-Countings3

目录Atcoder-Countings3IntroAC01 [ABC266G] Yet Another RGB Sequence(2045)ProblemSolutionAC02 [ARC162E] Strange Constraints(2780)ProblemSolutionAC03 [ARC1 ......
Atcoder-Countings Countings Atcoder