codeforces sorting round 1839

[Codeforces] CF1591C Minimize Distance

CF1591C Minimize Distance 题目 一条线上有 \(n\) (\(1 \le n \le 2 \cdot 10^5\))个仓库,第 \(i\) 个仓库的位置是 \(x_i\) (\(1 \le i \le n\))。 你有 \(n\) 箱货物,要分别运到这 \(n\) 个仓库里 ......
Codeforces Minimize Distance 1591C 1591

Educational Codeforces Round 52 E

提炼 显然我们可以把每一段拆开来单独考虑 我们该段有 A^len 选择 右边肯定只要不是相同 我们的集合就+1 Alen*(Alen -1) 当然要是相同也要算1 A^len 中间当然就是随便选啥都可以 void solve() { int n,m,A;cin>>n>>m>>A; vector<in ......
Educational Codeforces Round 52

Codeforces Round 908 (Div. 2) 补题C、D

Codeforces Round 908 (Div. 2) C. Anonymous Informant 思路 可以发现,每次操作后a数组的变化: \(a_1 a_2 a_3 a_4 ... a_x ... a_n\) \(->\) \(a_1\)\(_+\)\(_x\) \(a_2\)\(_+\) ......
Codeforces Round 908 Div

Codeforces Round 883 (Div. 3)

Codeforces Round 883 (Div. 3) A. Rudolph and Cut the Rope 题意:有一颗糖果在连在绳子上,求剪短多少根绳子,他能落地 思路:只要绳子长度比钉子高度大就不用减 #include <bits/stdc++.h> using namespace st ......
Codeforces Round 883 Div

Codeforces Round 911 (Div. 2)

Codeforces Round 911 (Div. 2) 基本情况 A题秒了。 B题条件没想明白,也不造点数据就无脑交,导致罚了不少时。 B. Laura and Operations 我先推出了,对于一个数,当另外两个数的个数之和为偶数时解可行,且这个数本身要能跟后面数替换。 比如 1 1 2 ......
Codeforces Round 911 Div

CF1830E Bully Sort

我永远喜欢数据结构。 洛谷 CF 对于一个排列 \(P_1\sim P_n\),定义 \(f(P)\) 为重复执行以下操作直至将其升序排序的操作次数: 找到一个位置 \(i\),使得其是满足 \(P_i\ne i\) 的位置中 \(P_i\) 最大的那个位置。 找到一个位置 \(j\),使得其是满足 ......
1830E Bully 1830 Sort CF

[LeetCode] 1685. Sum of Absolute Differences in a Sorted Array

You are given an integer array nums sorted in non-decreasing order. Build and return an integer array result with the same length as nums such that re ......
Differences LeetCode Absolute Sorted Array

Educational Codeforces Round 157 (Rated for Div. 2)

目录D. XOR Construction Educational Codeforces Round 157 (Rated for Div. 2) D. XOR Construction 方法一: 由题得 $ b_{i + 1} = a_i \oplus b_i = \cdots = b_1 \op ......
Educational Codeforces Round Rated 157

[Codeforces] CF1561C Deep Down Below

CF1561C Deep Down Below 时间限制:\(2s\) | 空间限制:\(1000MB\) 题面 题面翻译 \(T\) 组数据,每次给定 \(n\) 个任务,第 \(i\) 个任务给定 \(k_i\) 个怪物,每个怪物有一个能力值 \(a_{i,j}\) 你要按顺序把这 \(k_i\ ......
Codeforces 1561C Below 1561 Deep

Codeforces Round 910 (Div. 2)

https://codeforces.com/contest/1898 C题可以造一个大小为4的环,然后再造一个来回,这样就解决了%4=0,%4=2的情况,而奇数的情况显然无解。 #include<cstdio> #include<algorithm> #include<cstring> #incl ......
Codeforces Round 910 Div

Codeforces Round 829 (Div. 1)A1. Make Nonzero Sum (easy version)(思维找规律)

先考虑无解的情况:当n为奇数时无解 相邻的两个元素一定可以变成0 \[a[i] != a[i + 1]时, 分成[i, i], 和[i + 1, i + 1] \]\[a[i] = a[i + 1]时, 分成[i, i + 1] \]这两种情况对答案的贡献都是0,当n为奇数时我们总会有一个没办法凑成 ......
Codeforces 规律 思维 Nonzero version

Codeforces Round 731 Div3 A-G题解

Codeforces Round #731 (Div. 3) 在家打了好久COD和战雷,偶尔也得学习一下,要不然感觉时间都浪费了,游戏玩多了也腻,保持适当学习才能爽玩游戏。申请完了也不想做太难的题了,那么就来一场div3保持一下思维敏捷度吧。 A. Shortest Path with Obstac ......
题解 Codeforces Round Div3 731

Educational Codeforces Round 16 E

提炼 首先观察范围发现是1e7 好像是dp 但是发现直接朴素的dp发现是有环的 跑了一发dijk带log 答案是肯定没过 我们可以想一下 如果我要是一个10 我肯定不会从11转移过来 因为我不如先去5 再2 如果我要是一个9 我可以从8+1转移过来 也可以从52-1转移过来 这样我们就消除了环 in ......
Educational Codeforces Round 16

Educational Codeforces Round 158 (Rated for Div. 2)

A. Line Trip There is a road, which can be represented as a number line. You are located in the point \(0\) of the number line, and you want to travel ......
Educational Codeforces Round Rated 158

Codeforces Round 911 (Div. 2)补题C、D

Codeforces Round 911 (Div. 2) C. Anji's Binary Tree 思路 树形dp ac代码 #include <bits/stdc++.h> using namespace std; using i64 = long long; const i64 inf = ......
Codeforces Round 911 Div

Codeforces Round 911 (Div. 2)

B题 假设我们考虑能不能获得1,注意到b-c的奇偶性不会改变,然后特判一下只有一个大于0就行。 #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #include<map> #include<vector> ......
Codeforces Round 911 Div

CodeTON Round 7 (Div. 1 + Div. 2, Rated, Prizes!)

看到B官方题解写了一堆,而如果能注意到一些性质,几行就写完了 题意:给一个A,B构成的字符串,可以将“AB”翻转成"BA",问最多可以进行多少次翻转? 实际上在手动模拟以后发现,由于题目限制了每个位置只能翻转一次,所以情况简单了不少。 只要还没过最后一个B,那么最后一个B之前的所有A就会被反转。真正 ......
Div CodeTON Prizes Round Rated

Codeforces Round 911 (Div. 2) D

Codeforces Round 911 (Div. 2) D D. Small GCD 题意 定义\(f(a,b,c)\)为\(a,b,c\)中较小两个数的\(gcd\),给定数组\(a_{1...n}\),求\(\sum\limits_{i=1}^{n}\sum\limits_{j=i+1}^{ ......
Codeforces Round 911 Div

Day20.匿名函数的两种调用方式_max用法_min用法_sorted用法_map用法_filter用法_reduce用法

1.匿名函数的两种调用方式: 2.匿名函数求最大和求最小: 3.sorted用法和map用法: 4.filter的用法: 5.reduce的用法: ......
函数 方式 filter sorted reduce

CodeTON Round 7 Div. 1 + 2 (CF1896)

终于把 agc 交了。 A. Jagged Swaps 模拟即可。 B. AB Flipping 显然全是 \(\texttt{B}\) 的前缀和全是 \(\texttt{A}\) 的后缀都动不了。 答案是最后一个 \(\texttt{B}\) 的位置减第一个 \(\texttt{A}\) 的位置。 ......
CodeTON Round 1896 Div CF

CodeTON Round 7 (Div. 1 + Div. 2, Rated, Prizes!)

CodeTON Round 7 (Div. 1 + Div. 2, Rated, Prizes!) A - Jagged Swaps 思路:a2到an的数只要相邻为逆序都可以交换,只需要判断a1是否为1即可 #include<bits/stdc++.h> using namespace std; # ......
Div CodeTON Prizes Round Rated

Codeforces Round 894 (Div. 3)

Codeforces Round 894 (Div. 3) A. Gift Carpet 题意:判断一列一个字母有没有“vika” 思路:挨个枚举每一列 #include<bits/stdc++.h> using namespace std; char mp[25][25]; char x[]={' ......
Codeforces Round 894 Div

Codeforces Round 903 (Div. 3)

Codeforces Round 903 (Div. 3) A. Don't Try to Count 大概题意给你两个字符串a,b。a串可进行的操作为将整个a串复制到之前的a串后面(直接用a+a即可),然后看操作多少次可以让b串变为a串的子串如果不能就输出-1。 #include <iostrea ......
Codeforces Round 903 Div

【实例】Verilog对数据进行四舍五入(round)与饱和(saturation)截位

转自 https://blog.csdn.net/yan1111112/article/details/118498533 重点: 1、正数截位:直接看截掉的最高位是不是一,是的话进一。 负数截位:截的最高位为1且其它位不全是0进一 2、饱和,也就是大于求的结果,整数变为符号位为0,其它位为1;负数 ......
saturation 实例 Verilog 数据 round

verilog实现 floor, round 四舍五入 和 saturation 操作

floor, round和saturation是进行bit位削减时常用的方法,floor 和round用于削减低位,saturation用于削减高位。floor和round的区别在于,floor是将低位直接丢掉,而round则是在丢掉低位前先进行四舍五入。round和saturation的使用范例如 ......
saturation verilog floor round

Codeforces Round 911 (Div. 2)

Codeforces Round 911 (Div. 2) D - Small GCD 思路:求Σf(ai,aj,ak),其实就是所有gcd(ai,aj)的贡献,那么ijk的顺序就不重要了,首先可以将a排序。 可以枚举j,求出Σgcd(ai,aj),i<j,且k的个数等于Σgcd(ai,aj)贡献的 ......
Codeforces Round 911 Div

Codeforces Round 911 (Div. 2) D、E

CF1900D ​ 从小到大排列,第\(i\)个元素作为最大值对答案的贡献为\(\sum_{x=1}^{i-1} \sum_{y=x+1}^{i-1} gcd(a_x,a_y)\),即区间\([1,i-1]\)两两元素\(gcd\)和,记作\(val_{i-1}\)。然后考虑用第\(i\)个元素更新 ......
Codeforces Round 911 Div

Codeforces Round 911 (Div. 2) D. Small GCD

题目链接:https://codeforces.com/contest/1900/problem/D 对于已经排序好的数组 \(a\),我们需要计算: \[\sum_{i=1}^n\sum_{j=i+1}^n gcd(a_i, a_j) * (n - j) \]由于 \(\sum_{d|n} \ph ......
Codeforces Round Small 911 Div

E. Permutation Sorting 树状数组实现离线区间数点

题目链接🔗 题意解读:给定一串数组a,每次操作将所有的 a[i] != i 的数循环右移一位,直到所有的数都在自己的位置上。求对于1到n之间的每个i,需要移动多少次。 首先,先考虑移动次数的问题: 为了简化循环问题,考虑将数组长度手动扩充至 2 * n,对于所有的位置 i 上的一个 a[i] ,分 ......
数组 区间 Permutation Sorting

Codeforces Round 911 (Div. 2) D

D. Small GCD 题意 给定数组 \(a\) ,求出数组 \(a\) 中所有三元组中较小的两个元素的 \(gcd\) 的和. 分析 显然数组中元素的顺序不影响统计答案,为了方便先将数组排个序; 枚举中间的元素 \(a_j\) ,那么只有它前边的元素能与其产生贡献,它后边的元素个数就是这个贡献 ......
Codeforces Round 911 Div
共2000篇  :10/67页 首页上一页10下一页尾页