numbers lonely 1423k cf
CF1036F
[题目链接](https://codeforces.com/problemset/problem/1036/F) ## description $10^5$ 次询问 每次给定 $n\leq 10^{18}$, 求 2 到 $n$ 内质因子分解结果为 $p_{a_1}^{b_1}p_{a_2}^{b_ ......
CF1174E
[题目链接](https://codeforces.com/problemset/problem/1174/E) ## description 给定 $n\leq 10^6$, 求有多少个 $1$ 到 $n$ 的排列,对于一个 1 到 $n$ 的排列 $p$,$f(p)$ 表示 $p$ 的任意前缀内 ......
CF1852C Ina of the Mountain
*2400 https://codeforces.com/problemset/problem/1852/C 如果没有 $\mod k$ 的限制的话,我们都会做,因为都是正数,那么 $\sum_i^n d_i>0$,因此,答案即为 $\sum[d_i>0]d_i$。 但是现在多了一个操作,即为区间加 ......
【题解】CF2600DP 选练(23.9.5-23.9.6)
低情商:感觉是比较套路的 高情商:十分 educational!!! ## CF258D Little Elephant and Broken Sorting ### 题目描述: 有一个 $[1,n]$ 的排列 $a$,会进行 $m$ 次操作,操作为交换 $(a_i,a_j)$。每次操作都有 $50 ......
CF626F Group Projects
发现直接做非常困难,考虑将能力值排序后从小到大插入。 令 $f_{i,j,l}$ 表示前 $i$ 个人,有 $j$ 组需要继续加人,不和谐度之和**恰好**为 $l$ 的方案数。此时加入一个人对不和谐度之和产生的贡献为 $t=j\times(a_{i+1}-a_i)$。分三种情况转移: - 组数加一 ......
LCM Sum (CF E ) (正男则反, 二维数点/二维偏序, 大胆的抽象化简数学式子, 打表找规律)
思路: CF1712 E1/E2 LCM Sum (easy/hard version) 二维数点/二维偏序: 二维前缀和+扫描线+树状数组+ 离线处理 应用: 求 Q次询问, L-R内 x-y的 点的数量(矩形内点的数量) 直接用二维前缀和, 时间复杂度, 一定不允许, 发现 二维前缀和是由 4个 ......
CF724G Xor-matic Number of the Graph
[题目链接](https://codeforces.com/problemset/problem/724/G) 不妨先看一道更为基础的题:[CF845G](https://codeforces.com/problemset/problem/845/G)以及[它的题解](https://www.cnb ......
CF444C DZY Loves Colors
## [$DZY$ $Loves$ $Colors$](https://codeforces.com/problemset/problem/444/C) ### 一、题面翻译 有一个 $n$ 个元素组成的序列,每个元素有两个属性:颜色 $c_i$ 和权值$w_i$。$c_i$ 初始为$i$,$w_i ......
CF1860D 题解
在 Codeforces 上看到了这题的 $\mathcal{O}(n ^ 4 / \omega)$ 做法,和大家分享一下。 [原版 Solution 链接](https://codeforces.com/blog/entry/119504?#comment-1060285) 记 $d$ 为原字符串 ......
【题解】CF1852D Miriany and Matchstick
考虑 `dp`,设 $f_{i,0/1}$ 表示考虑到前 $i$ 位,且第 $i$ 位填入 A/B 可能的答案集合,显然地朴素转移时间复杂度 $O(n^2)$。 试分析 `dp` 性质,观察发现所有 `dp` 中得到的集合为区间内抠去至多一个点。 > > 证明 > 我们首先来观察转移过程是怎样的。第 ......
Codeforces Round 861 (Div. 2) A. Lucky Numbers
定义一个数的幸运值是这个数的数位的最大值减去最小值,如 $luckiness_{769} = 9 - 6 = 3$ 。给出 $l$ $r$ ,求 $[l, r]$ 中最幸运的数,若最幸运的数有多个,任意一个为答案。 考虑拆分数位,然后枚举。以 $O(d)$ 的复杂度计算幸运值。则线性扫一遍的复杂度为 ......
【题解】CF1852C Ina of the Mountain
我们先从题目的一部分入手。 如果说,我们没有当一个数为 $0$ 时,让这个数变成 $k$ 的性质,我们如何求答案呢? 很简单,在图上就是: 绿色线段的长度加起来即为答案(本图中是 $6$) 我们考虑很显然地,将一个数从 $0$ 变为 $k$ 即为将一个数一开始加上 $k$ 我们如果要让第 $i$ 列 ......
1521A - Nastia and Nearly Good Numbers
## A. Nastia and Nearly Good Numbers https://codeforces.com/problemset/problem/1521/A ```python """ 思路: 1.就是普通的打印,NO的情况是只有b=1的时候才会出现,其他的都是YES,如果不想再继续分 ......
row_number函数的不稳定性
本文分享自华为云社区《row_number函数的不稳定性》,作者: nullptr_ 。 row_number为窗口函数,用来为各组内数据生成连续排号 基础用法 postgres=# select id,name,age,row_number() over() from test; id | nam ......
CF1695D2 Tree Queries (Hard Version)
[原题](https://codeforces.com/problemset/problem/1695/D2) [翻译](https://www.luogu.com.cn/problem/CF1695D2) $$ \large{\color{#ff0000}{\text{被xjk搏杀了,wtcl}} ......
CF845G Shortest Path Problem?
[原题链接](https://codeforces.com/problemset/problem/845/G) 不妨先了解几个前置知识/引理: 异或的抵消性质: * $a\oplus a=0$ * $\forall b[b\not= a],a\oplus b\not=0$ * $(a\oplus b ......
【题解】CF1852B Imbalanced Arrays
我们假设当前出长度为 $len$,那么我们在序列中一定有一个 $len/0$,因为一定有一个绝对值最大的数,如果这个数是正数在原序列中就是 $len$,是负数在原序列中即为 $0$。 由上文,我们可以得到,一定不能有 $len$ 和 $0$ 同时出现的情况,也一定不能有 $len$ 和 $now$ ......
【题解】Educational Codeforces Round 145(CF1809)
## A.Garland ### 题目描述: 有 $4$ 只灯泡,第 $i$ 只灯泡的颜色为 $s_i$ 。 一开始,所有灯泡都是关着的,你需要把它们都打开。你可以进行数次操作,每次操作改变一个灯泡的状态,即打开原本关着的灯泡或关上原本亮着的灯泡。第一次操作可选择任何灯泡,此后每一次被操作的灯泡的颜 ......
[CF1768F]Wonderful Jump
[Wonderful Jump](https://www.luogu.com.cn/problem/CF1768F) 题目看错了,以为能往回跳...... 暴力转移式 $$ dp_i=min(dp_i,dp_j+\min_{k=j}^ia_k\times(i-j)^2) $$ 你会发现这个没啥单调性 ......
CF1854 题解
# CF1854 题解 ### A 首先考虑只有非负的情况,次数完全可以接受 $19$ 次,所以直接用 $19$ 次做一次前缀和就可以保证单调不降了。 现在有了负数,考虑将负数变成正数,选出正数当中的最大值,然后用 $a_i + a_i \to a_i$ 这样自增的方式让它的绝对值大于负数最大值,因 ......
CF1852 题解
# CF1852 题解 ## A Ntarsis' Set ### 题意 有一个集合,初始状态里面有数字 $1$、$2$、$3$、$4$、$5$、......、$10^{1000}$。 现在给你一个长度为 $n$ 数组 $a (1\leq a_i \leq 10^9 )$,要进行 $k$ 次操作,每 ......
【题解】CF1852A Ntarsis' Set
考虑我们先手模一下样例: $$ \begin{cases} 1&3&5&6&7\\ 2&8&10&11&12\\ 4&13&15&16&17 \end{cases} $$ ???一脸疑惑,有什么规律吗?真有,但是很难看出来捏。 正难则反,我们考虑如果知道操作一次后一个数的位置,我们可以很容易推出,操 ......
XOR and Favorite Number题解
## XOR and Favorite Number题解 ### 思路引导 这一道题主要是为了说明莫队算法和分块之间的联系。 先主要讲讲莫队的用处吧。 它是个离线算法,维护两个指针l,r。 移动l和r的时候顺便进行更改,维护好l-r区间内的某个值。 对于询问区间的排序,遵循l所在的分块相同,其次是r ......
[CF1641D] Two Arrays
## 题目描述 Sam changed his school and on the first biology lesson he got a very interesting task about genes. You are given $ n $ arrays, the $ i $ -th o ......
input number 类型输入中文 光标异常
![](https://img2023.cnblogs.com/blog/2184988/202309/2184988-20230904162833449-1057842854.png) ``` input number 类型输入中文 光标异常 const input=document.queryS ......
[CF1830E] Bully Sort
## 题目描述 On a permutation $ p $ of length $ n $ , we define a bully swap as follows: - Let $ i $ be the index of the largest element $ p_i $ such that ......
[CF1599A] Weights
## 题目描述 You are given an array $ A $ of length $ N $ weights of masses $ A_1 $ , $ A_2 $ ... $ A_N $ . No two weights have the same mass. You can put ......
[CF1830D] Mex Tree
## 题目描述 You are given a tree with $ n $ nodes. For each node, you either color it in $ 0 $ or $ 1 $ . The value of a path $ (u,v) $ is equal to the ME ......
[CF1854C] Expected Destruction
## 题目描述 You have a set $ S $ of $ n $ distinct integers between $ 1 $ and $ m $ . Each second you do the following steps: 1. Pick an element $ x $ in ......