codeforces country binary ralph

CodeForces 合集

# 1838E. Count Supersequences https://codeforces.com/contest/1838/problem/E ## 题意 给定 $n, m, k$,一个长度为 $n$ 的序列 $a = (a_1, a_2, \dots, a_n)$,满足 $1 \leq a ......
CodeForces

Codeforces Round 880 (Div. 2) C. k-th equality

看好久题目了,题目大意是给定三个位数A,B,C和一个k,要求求所有满足要求的a+b=c等式中的第k个等式 等式按字典序由小到大枚举,例如1+9=10和2+6=8中1+9=10比2+6=8小 思路我们首先求出a,b,c的取值范围,然后先确定a,对于每一个确定的a都有一个确定的b和c区间与之对应,并且a ......
Codeforces equality Round k-th 880

Codeforces Round 879 (Div. 2) 题解

寄!大!了! Rating -= 124. ![image](https://img2023.cnblogs.com/blog/3143679/202306/3143679-20230619222246244-5109748.png) (恼) https://codeforces.com/conte ......
题解 Codeforces Round 879 Div

Codeforces 1834 / Codeforces Round #879 (Div. 2)

[TOC] ### Contest Link [Codeforces Round #879 (Div. 2)](https://codeforces.com/contest/1834) ### Problem B [Maximum Strength](https://codeforces.com/c ......
Codeforces Round 1834 879 Div

Codeforces Round 880 (Div. 2) B. Astrophysicists

昨天晚上卡B题了,掉大分,qwq 现在回想起来昨天没反应过来 题目要求为公司节省最多的钱 我们可以发现如果n个人,每个人的分的钱都小于g/2且者n个人分的钱加起来恰好为k*g的话则公司一分钱都不用花 第一种情况 假设每个人分的钱都为h则最理想的情况为h*n>=k*g且h<g/2,即h=g/2-1 如 ......
Astrophysicists Codeforces Round 880 Div

Codeforces Round 879 (Div

# [Codeforces Round 879 (Div. 2)](https://codeforces.com/contest/1834) A-D题解 第一次写题解,请见谅O3O a题代码是完整的,后面的只显示主要内容的代码 ## A. Unit Array 题目解释 他会给你一个只包含1或者-1 ......
Codeforces Round 879 Div

Codeforces1 #879 div.2

第一次参加codeforces比赛,只能做出来俩题,第三个题思路也就一半一半,估计是想不出来的那种,赛后问了下带佬,把我思路添加了点,最终还是A了 争取稳过第三题! //A //统计1,-1出现的次数,然后如果-1是奇数,让他变成偶数,次数+1 //因为总乘积要是正1,然后再变-1为1,直到>=0为 ......
Codeforces1 Codeforces 879 div

Codeforces Round 880 (Div. 2) 题解 A - C

## 写在前面 感觉题目是一坨。 A愣了一会,BC同开然后半天读不懂题。写出来发现毛算法都没有,div1那边更是大寄。DEF三题过题数个位数根本看都看不来。总结为很烂的一场。 ## [A](https://codeforces.com/contest/1836/problem/A). Destroy ......
题解 Codeforces Round 880 Div

Educational Codeforces Round 150 (Rated for Div. 2) C. Ranom Numbers

#include <iostream> #include <string> #include <cstring> #include <algorithm> #include <cmath> using namespace std; const int N=2e5+10; typedef long l ......
Educational Codeforces Numbers Round Rated

Educational Codeforces Round 150 (Rated for Div. 2) B. Keep it Beautiful

#include <iostream> #include <cstring> using namespace std; const int N=2e5+10; int a[N],res[N]; int t; int main(){ cin>>t; while(t--){ int n; cin>>n; ......
Educational Codeforces Beautiful Round Rated

CodeForces 1841C Ranom Numbers

[洛谷传送门](https://www.luogu.com.cn/problem/CF1841C "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1841/C "CF 传送门") 先反转 $s$ 串,然后考虑 dp,设 $f_{ ......
CodeForces Numbers 1841C Ranom 1841

binary_search 二分查找

1.在列表中获取中间位置的值 2.将中间值和所需要查找的值做对比, 如果相等则返回中间值的位置 3.如果中间值小于所需要查找的值, 则将查找范围缩小到 left 至 mid-1 (即right 修改为 mid-1) 4.如果中间值大于所需要查找的值, 则将查找范围修改为 mid+1 至 right ......
binary_search binary search

Educational Codeforces Round 150 (Rated for Div. 2)题解(A~D)

比赛地址 A. Game with Board 题意: 给出一个包含n个1的数组,Alice和Bob轮流操作(Alice先手),每次操作可以将若干个(最少为两个)不同的元素相加,组成一个新的元素插入数组中,同时删去被操作的元素。当轮到某名玩家时无法再进行操作,则该玩家获胜。 思路: 容易想到,当n= ......
题解 Educational Codeforces Round Rated

Add Binary

Given two binary strings a and b, return their sum as a binary string. **Example 1:** ``` Input: a = "11", b = "1" Output: "100" ``` **Example 2:** `` ......
Binary Add

Codeforces Round 855 (Div. 3)

`https://codeforces.com/contest/1800` **E. Unforgivable Curse** 题意:输入两个字符串s,t , 每次修改可以交换相距k或k+1位置的字母,能否将将s修改为t。 方法:首先,两个字符串必须由相同元素,且每种元素的个数相等。其次,元素可以先 ......
Codeforces Round 855 Div

CodeForces 1839E Decreasing Game

[洛谷传送门](https://www.luogu.com.cn/problem/CF1839E "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1839/E "CF 传送门") 不会,不知道该如何评价。确实是自己的问题。 这种 ......
CodeForces Decreasing 1839E 1839 Game

Educational Codeforces Round 150 (Rated for Div. 2) 题解

https://codeforces.com/contest/1841 https://codeforces.com/contest/1841/problems # D. Pairs of Segments https://codeforces.com/contest/1841/problem/D ......
题解 Educational Codeforces Round Rated

Codeforces Round 877 (Div.2) 题解 A - D

## [A](https://codeforces.com/contest/1838/problem/A). Blackboard List ### 题目大意 起初黑板上有两个数,现在不断选取两个数作出他们俩差的绝对值并写在黑板上,如此往复直到黑板上有 $n$ 个数。现在给定这 $n$ 个数,问起初 ......
题解 Codeforces Round 877 Div

Codeforces Round 877 (Div. 2)

# Preface 补题 这场补题的时候直接成腐乳了,A题挂两发,B题挂两发,C题挂一发是真的抽象 虽然D是个套路题看一眼就秒了,但如果真的比赛时候打真要罚时爆炸了的说 后面的EF还是做不来啊岂可修,不过都很有启发性让人感觉神清气爽,不像傻逼蓝桥杯花钱买罪受 # A. Blackboard List ......
Codeforces Round 877 Div

Codeforces Round 876 Div2 A-D题解

# Codeforces Round 876 Div2 A-D题解 # A.The Good Array 这个题就是问你对于 $i \leq n$,要求前面后面至少 $ceil(\frac{i}{k})$ 个 1 那我们就贪心的每k个放一个1,或者直接用数学算一下就好了 AC 代码 ```cpp # ......
题解 Codeforces Round Div2 876

[Codeforces Round 876 (Div. 2)][Codeforces 1839D. Ball Sorting]

题目链接:[D - Ball Sorting](https://codeforces.com/contest/1839/problem/D) 题目大意:需要对一个排列按照指定操作进行排序。操作一:在数字间插入一个特殊点,可执行不超过 $k$ 次;操作二:将在特殊点旁的数移动到任意位置。所有操作结束后 ......
Codeforces Sorting Round 1839 Ball

Codeforces 1188D Make Equal

设最终所有数变为的值为 $u$,$\operatorname{bitcount}(x)$ 为 $x$ 二进制上为 $1$ 的位数,由题可得答案即为 $\sum\limits_{i = 1}^n \operatorname{bitcount}(u - a_i)$。 此时让 $a_i$ 从小到大排序,答 ......
Codeforces 1188D Equal 1188 Make

Codeforces 1626 C

# [1626 C](https://codeforces.com/problemset/problem/1626/C) ## 题意 抽象出题意:给出n个区间的结尾以及它的区间长度,然后每一段连续区间的贡献为$\sum_{i=1}^{len} i$ ,求总贡献。 ## 思路 处理出每个区间的开头结尾 ......
Codeforces 1626

CodeForces 1840G In Search of Truth

[洛谷传送门](https://www.luogu.com.cn/problem/CF1840G2 "洛谷传送门") [CF 传送门](https://codeforces.com/problemset/problem/1840/G2 "CF 传送门") 每次询问获得的信息只有当前所在位置的数字。考 ......
CodeForces Search 1840G Truth 1840

Codeforces 1514 C

# [1514 C](https://codeforces.com/problemset/problem/1514/C) ## 题意 给出一个数n,求[1,2,3...n-1]的某个最长子序列,这个子序列的元素乘积模n余1。 ## 思路 这是个思维题,一个数学公式 $$x \equiv 1(mod  ......
Codeforces 1514

Codeforces 1515 B

# [1515 B](https://codeforces.com/contest/1515/problem/D) ## 题意 有n只袜子(n为偶数),但左袜子有L只,右袜子有R只,每只袜子的颜色为$C_i$,可以进行以下操作:换袜子的方向、或者将袜子变色,问进行多少次操作后变成(n/2)对袜子 # ......
Codeforces 1515

Codeforces Round 878 (Div. 3) 题解 A - G2

## 吐槽在前面 太菜了赛后6min过掉的G1,本来以为是因为G1没出没上蓝,结果System Test直接给我C题卡掉了,一看发现我数组开小了一倍,最后险些掉分。 总之就是状况频出的滑铁卢战役qwq。 ## [A](https://codeforces.com/contest/1840/probl ......
题解 Codeforces Round 878 Div

Codeforces Round 876 (Div. 2) 题解 A - D

## [A](https://codeforces.com/contest/1839/problem/A). The Good Array ### 题目大意 给定两个整数 $n$ 和 $k$,规定一个$01$数列为好的的条件是,对于$1\sim n$中任意的 $i$,都有: - $a$ 的前 $i$ ......
题解 Codeforces Round 876 Div

codeforces.com/contest/1553/problem/B

# [简单字符串哈希](https://codeforces.com/contest/1553/problem/B) ## 题意 给一个字符串s和t,问从s的某个位置开始,向右到某个点后再向左,顺序遍历到的字符形成的字符串可否为t。 ## 思路 数据只有500,$O(n^3)$可过,枚举转折点,然后 ......
codeforces contest problem 1553 com

【leetcode】104. Maximum Depth of Binary Tree

给定一个二叉树,找出其最大深度。 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。 **说明:** 叶子节点是指没有子节点的节点。 **示例:** 给定二叉树 `[3,9,20,null,null,15,7]`, ``` 3 / \ 9 20 / \ 15 7 ``` 返回它的最大深度 3 ......
leetcode Maximum Binary Depth Tree