codeforces different arrays 1783d

Codeforces Round 901 (Div. 2) - A B

目录A. Jellyfish and UndertaleB. Jellyfish and Game 题目传送门 A. Jellyfish and Undertale 贪心考虑每次时间减到 1 时能否使用工具加时间,注意总时间上限是 a B. Jellyfish and Game 贪心考虑美每位选手肯 ......
Codeforces Round 901 Div

CodeForces 1864H Asterism Stream

洛谷传送门 CF 传送门 好题。 考虑计算 \(x\) 落在 \([1, n - 1]\) 的概率。设 \(f_i\) 为 \(x\) 经过 \(i\) 的概率,答案即为 \(\sum\limits_{i = 1}^{n - 1} f_i\)。 \(f\) 有一个朴素的递推: \[f_i = \be ......
CodeForces Asterism Stream 1864H 1864

Codeforces Round 888 (Div. 3)DEF

Codeforces Round 888 (Div. 3)DEF D. Prefix Permutation Sums 题意:给你一个长度为 \(n - 1\) 的数组,是否能找出一个长度为 \(n\) 的排列,求出这个排列的前缀和,去掉前缀和数组的任意一个元素之后和原来的数组相等。 例如 \([6 ......
Codeforces Round 888 Div DEF

Educational Codeforces Round 155 (Rated for Div. 2)

\(A. Rigged!\) 直接取第一个人能举起的最大重量看他是否是冠军即可。 void solve(){ int n=read(); int fx=read(),ft=read(); int ans=fx; for(int i=1;i<n;i++){ int x=read(),t=read(); ......
Educational Codeforces Round Rated 155

Codeforces 449E - Jzzhu and Squares

显然任意一个顶点是关键点的正方形都可以用两个量来刻画:以其任意一条边对应的直角边平行于坐标轴的直角三角形的两直角边的长度 \(i,j\)(在下文中记这样的正方形为正方形 \((i,j)\))。对于 \(i+j\) 相同的两种正方形,显然一个 \(n\times m\) 的点阵中这样的两正方形个数是相 ......
Codeforces Squares Jzzhu 449E 449

Codeforces 1874F - Jellyfish and OEIS

考虑对 \(\sum m_i-i+1\) 个不可行的集合进行容斥,即钦定一些区间集,要求它们对应的 \(p_l,p_{l+1},\cdots,p_r\) 必须是 \([l,r]\) 的排列,计算方案数乘以容斥系数之和。 如果容斥的集合中存在相交的区间,那么这个方案数其实不太好计算。不过根据区间的性质 ......
Codeforces Jellyfish 1874F 1874 OEIS

Codeforces Round 898 (Div. 4) A~H

Codeforces Round 898 (Div. 4) A~H A. Short Sort 题意:输出不一样的字符的个数 思路:模拟即可 // AC one more times // nndbk #include <bits/stdc++.h> using namespace std; typ ......
Codeforces Round 898 Div

Codeforces Round 901 (Div. 2)

Preface 摆烂人闪总出列,开个小号摆烂打Div2,龟速1h写完前四题后发现后面三个题过的人数是1/2/1 遂假装挣扎了下看了下EF题面,发现F很可做就开始推式子,后面一看妈的样例都过不去才发现题目看错了 还好拿的新号打的,遂直接无限活力,启动! 后面看了下F原来比我想的还简单来着,E的做法确实 ......
Codeforces Round 901 Div

Codeforces Round 901 (Div. 2)

目录写在前面ABCDE写在最后 写在前面 比赛地址:https://codeforces.com/contest/1875。 爱丽数码我真的好喜欢你啊为了你我要定制你的帆布包口牙!!!! A 显然只会在剩余时间为 1 时使用工具,模拟即可。 // /* By:Luckyblock */ #inclu ......
Codeforces Round 901 Div

「题解」Codeforces Round 894 (Div. 3)

A. Gift Carpet Problem 题目 Sol & Code 签到题 #include <bits/stdc++.h> #define N 21 typedef long long ll; int min(int a, int b) { return a < b ? a : b; } i ......
题解 Codeforces Round 894 Div

Go - Creating JSON Data Byte Arrays from Structs

Problem: You want to create JSON data from a struct. Solution: Create the structs then use the json.Marshal or json.MarshalIndent to marshal the data ......
Creating Structs Arrays Byte Data

CodeForces-1276#B 题解

正文 这是样例 1 第 1 组数据的图。 让我们观察一下,路径 1->6、1->7、2->6、2->7 是可行的,所以答案为 4。 上述路径中好像点 4 没有贡献? 再看看样例 1 第 2 组数据的图。 发现点 1 和点 4 相互之间存在其他路径,无需经过点 \(a\) 和点 \(b\)。 综上,我 ......
题解 CodeForces 1276

Array常用方法

1.Arrays.toString()方法方法作用:快速输出数组内容 int[] a = {1,2,3,4,5}; System.out.println(Arrays.toString(a)); // 输出格式:[1,2,3,4,5] 2.Arrays.sort()方法方法作用:给数组排序,默认升序 ......
常用 方法 Array

Codeforces Round 730 (Div. 2) B. Customising the Track

有 \(n\) 条高速公路,第 \(i\) 条告诉公路上的车流为 \(a_i\) 。现在可以执行以下操作任意次: 将第 \(i\) 条高速公路上的一辆车移到第 \(j\) 条高速公路。 需要求最小的 \(\sum_{i = 1}^{n}\sum_{j=i+1}^{n} |a_i - a_j|\) 。 ......
Customising Codeforces Round Track 730

Educational Codeforces Round 112 (Rated for Div. 2) A. PizzaForces

有三种披萨:\(6\)、\(8\)、\(10\) 块披萨。制作时间分别需要:\(15\)、\(20\)、\(25\) 分钟。现在有 \(n\) 个人,每人需要一块披萨。询问使所有人能获得披萨的最快时间。 观察:发现三种披萨的性价比都一样。(否则按最优性价比贪心) 需要让得到的披萨数量 \(m \ge ......

题解 Codeforces Round 901 (Div. 1) / CF1874A~E

题解 Codeforces Round 901 (Div. 1) / CF1874A~E 比赛情况:过了 AB。赛后发现 B 是假复杂度。 https://codeforc.es/contest/1874 A. Jellyfish and Game Problem Alice & Bob 又在博弈, ......
题解 Codeforces Round 1874 901

Codeforces Round #885 (Div. 2)

赛时A题意理解错误,导致A调试半小时没出样例,直接提前下班-->https://codeforces.com/contest/1848 A. Jellyfish and Undertale 题意:初始时长为b的定时炸弹,没秒从n个工具中选一个加时长\(x_i\),每次加时不能超过a,并流失一秒。问: ......
Codeforces Round 885 Div

Codeforces 1765H 题解

题目大意 题目大意 给定一个 \(n\) 个点和 \(m\) 条边的有向图,并给定 \(p_1, p_2, \cdots, p_n\) 表示第 \(i\) 个点的拓扑序必须小于等于 \(p_i\),求出每个点的最小拓扑序。 题解 题解 题目要求拓扑序尽量小,转换一下就是在反图上拓扑序尽量大。考虑拓扑 ......
题解 Codeforces 1765H 1765

Codeforces Round 699 & 772题解

Codeforces Round 699 & 772题解 今天手感确实不错,看来合理的训练配合合理的休息是很重要的。前些日子的努力没白费。不过,怎么说呢,现在的形势不是我把算法题和基础知识做好的就行了,该从系统的角度去作为一个ld去思考问题了,感觉自己还是有点欠缺的,不过我也在积极努力的学习中,希望 ......
题解 Codeforces Round 699 772

Codeforces Round 901 (Div

C. Jellyfish and Green Apple 题解 显然\(n \% m =0\),答案一定为\(0\) 如果\(n > m\),我们显然可以将\(n / m\)的苹果分给每个人,然后再处理$n % m $ 如果\(n < m\),我们一定会将所有苹果一直对半切直到\(n > m\),所 ......
Codeforces Round 901 Div

Codeforces Round 895 (Div. 3)

A题简单的模拟计算,注意上取整的实现。 B题计算每个房间对应的每个最迟时间点,在这些时间点最取最小值,保证能安全通过所有房间。 D题拿到手就可以发现是贪心,但发现两部分会有冲突,也就是重复计算的部分。故提前找到两个数的lcm然后不计算lcm的倍数,为其他参与计算的数安排剩余数种的最大值和最小值,最后 ......
Codeforces Round 895 Div

Codeforces 1278D 题解

题目大意 题目大意 给你 \(n\) ( \(1\leqslant n\leqslant 5\cdot 10^5\) ) 条线段 \([l_1, r_1], [l_2, r_2], \cdots, [l_n, r_n]\) ( \(1\le l_i < r_i\le 2n\) )。保证每条线段的端点 ......
题解 Codeforces 1278D 1278

Codeforces Round 811 (Div. 3)

A. Everyone Loves to Sleep #include<bits/stdc++.h> using namespace std; void solve() { int n, h, m, t; cin >> n >> h >> m; t = h * 60 + m; vector<int> ......
Codeforces Round 811 Div

Codeforces 1702G2 题解

题目大意 给出一个大小为 \(n\) 的树,\(q\) 次询问,每次给出一个大小为 \(m\) 的点集,判断是否有一条链覆盖这些点(这条链可以经过其他点)。 \(n,\sum m\leqslant 2\cdot 10^5\) , \(q\leqslant 10^5\)。 提示 提示 1 思考将 $m ......
题解 Codeforces 1702G2 1702G 1702

CodeForces 1874B Jellyfish and Math

洛谷传送门 CF 传送门 看到这种操作乱七八糟不能直接算的题,可以考虑最短路。 对于 \(a, b, c, d, m\) 按位考虑,发现相同的 \((a, b, m)\) 无论如何操作必然还是相同的。 于是考虑对于每个可能的 \((0/1, 0/1, 0/1)\),所有终态有 \((c = 0/1, ......
CodeForces Jellyfish 1874B 1874 Math

Javascript之Object、Array

Object.keys 对象的键转化为数组 Object.values 对象的属性值转化为数组 Object.assign 对象的合并 Array.from() 伪数组对象的属性值转化为数组。类似Object.values Array.reduce 将数组的值减为单个值(从左到右) ......
Javascript Object Array

「题解」Codeforces Round 895 (Div. 3)

A. Two Vessels Problem 题目 Sol & Code 签到题 #include <bits/stdc++.h> typedef long long ll; int min(int a, int b) { return a < b ? a : b; } int max(int a, ......
题解 Codeforces Round 895 Div

题解-CF402D Upgrading Array

题意 已知 \(m\) 个坏素数 \(b_i\),定义一个数 \(x\) 的分值 \(f(x)=f(\frac xp)+k\),其中 \(p\) 为 \(x\) 的最小质因数,如果 \(p\) 为坏素数则 \(k=-1\),否则 \(k=1\),初始 \(f(1)=0\),一个数组的分值为其中所有数 ......
题解 Upgrading Array 402 CF

Codeforces Round 901 (Div. 2)

Codeforces Round 901 (Div. 2) A - Jellyfish and Undertale 解题思路: 卡在最后秒放。 若\(x_i > (a - 1)\):那么该\(x_i\)的贡献为\(a - 1\)。 否则,该\(x_i\)的贡献为\(x_i\)。 代码: #inclu ......
Codeforces Round 901 Div

Codeforces Round 653 (Div. 3)

A*800: 给定 x,y,n。 找出k%x==y && k<=n。 让 t=(n-y)/x, 答案就是t*x+y B*900: 如果说n有除了2,3以外的质数,答案就是-1 让c2=2出了多少次, c3情况相同 如果c2>c3,答案也是-1因为不可能移除掉那些2 其他情况:答案就是c3+(c3-c ......
Codeforces Round 653 Div