
Codeforces
文章平均质量分 51
陵游gentian
这个作者很懒,什么都没留下…
展开
-
Educational Codeforces Round 117 (Rated for Div. 2) ABCD
A. DistanceB. Special PermutationC. Chat BanD. X-Magic PairA. Distance思路分析读懂题意,分情况讨论一下即可AC代码#include<bits/stdc++.h>using namespace std;typedef long long ll;int T;int main() { cin >> T; while (T--) { int x, y;原创 2021-11-22 23:42:48 · 160 阅读 · 0 评论 -
Codeforces Round #753 (Div. 3) ABCD
A. Linear KeyboardB. Odd GrasshopperC. Minimum ExtractionD. Blue-Red PermutationA. Linear Keyboard思路分析思维题都不算。。。读懂题意。。。有手就行。。。AC代码#include <iostream>#include <algorithm>using namespace std;typedef pair<int,int> PII;typedef lo原创 2021-11-19 09:08:50 · 296 阅读 · 0 评论 -
Codeforces Round #755 Div. 2 ABCD
A. Mathematical AdditionB. Coloring RectanglesC. Two ArraysD. Guess the PermutationA. Mathematical Addition思路分析题目意思就是一个一个等价方程,给出 u 和 v,构造 x 和 y 使得方程成立我的想法是化简一下方程,最后得到的结果是 x * v * v + y * u * u = 0,又知道 u 和 v,所以就能构造出来了注意数据范围开 long long(因此WA了一发。。。)A原创 2021-11-16 10:54:01 · 550 阅读 · 0 评论 -
Codeforces Round #743 (Div. 2) B. Swaps
思路:坐标存储 + 双指针 + 贪心AC代码#include <bits/stdc++.h>#define LL long long#define INF 0x3f3f3f3fusing namespace std; typedef pair<int,int> p;const int N = 1e5 + 10; int b[N];p a[N]; int n, t;int ans; int main() { while(cin >>..原创 2021-09-28 21:25:53 · 92 阅读 · 0 评论 -
Codeforces Round #743 (Div. 2) A. Countdown
简单思维题,直接上AC代码了AC代码#include <bits/stdc++.h>#define LL long long using namespace std;const int N = 1e5 + 10; char num[110];int n, t;int sum; int main() { while(cin >> t) { while(t--) { sum = 0; ci..原创 2021-09-28 21:19:29 · 94 阅读 · 0 评论 -
Codeforces Round #741 (Div. 2) A. The Miracle and the Sleeper
A. The Miracle and the Sleeper题目大意给两个数 l,r 让你在其中找到 a,b 求的 a%b 取得最大值,需要满足 ????≥????≥????≥????.思路首先可以假设确定a,让a尽可能的大,即 a = r;然后思考b,b 最小值必须大于 l ,如果让 a%b 尽可能取得最大值,b 最大是 2a-1所以只需要让b取得 l 和 2a - 1 的最大值即可AC代码//#include <bits/stdc++.h>#include <ios原创 2021-09-02 11:28:01 · 167 阅读 · 0 评论 -
Codeforces Round #719 (Div. 3) C. Not Adjacent Matrix
C. Not Adjacent Matrix题目大意:输入一个整数n,让你构造一个大小为 n * n 的矩阵该矩阵需满足以下条件:矩阵中的每个数字为 [1, n*n] 且不能重复矩阵中相邻的两个格子数字之差的绝对值不能为 1如果可以构造,则输出你构造的矩阵,否则输出 -1思路分析:其实很明显的可以感受到,当 n 为 1 和 2 时,需要进行特判,当 n 大于等于 3 时一定有解。我的想法是:从 1 开始 依次 +2 进行输出,奇数输出完后,再输出偶数也就是当 n = 3 时,将会原创 2021-05-30 20:52:09 · 247 阅读 · 0 评论 -
Codeforces Round #719 (Div. 3) B. Ordinary Numbers
B. Ordinary Numbers题目大意:给你一个数,让你判断这个数的前面有多少个类似与 1,11,111这样的数思路分析:读入的时候,可以以字符串的方式读入,方便判断位数,也方便后续的一些操作~AC代码:#include <bits/stdc++.h> using namespace std; int n; int main() { cin >> n; while (n--) { string s; c原创 2021-05-29 21:44:46 · 151 阅读 · 0 评论 -
Codeforces Round #719 (Div. 3) A. Do Not Be Distracted!
A. Do Not Be Distracted!题目大意:输入一个m长度的字符串,若左边出现的字母在后方(非并列)重新出现,则输出 YES,否则输出 NO思路分析:双指针扫一遍嘛,从前往后扫,时间复杂度是 O(n^2)AC代码:#include <bits/stdc++.h> using namespace std; int n, m; char str[1010]; int main() { cin >> n; while (n--)原创 2021-05-29 21:33:40 · 158 阅读 · 0 评论 -
Codeforces Round #699 (Div. 2) B. New Colony
1481 B. New Colony题目大意:给个n,kn个山峰,k个小球问你如果可以滚下,输出-1不可以,输出最后一个小球填补的位置思路分析:现在看来是一个很朴素的模拟题了。。。也找出了比赛时代码错误的原因(竟是思路分析错了!太偷懒了!想的要朴素一点!)AC代码:#include<iostream>using namespace std;const int N = 110;int h[N];int n, k;int main() { int t;原创 2021-02-06 23:39:31 · 151 阅读 · 0 评论 -
Codeforces Round #693 (Div. 3) B. Fair Division(800)
1472 B. Fair Division题目大意:给你一堆由面值为1或2的硬币,问你能不能把这堆硬币分成两堆,使得两堆硬币面值和相同。思路分析:可以发现如果硬币总和是奇数,则一定无法平均分配在和为偶数的前提下,如果面值为2的硬币数量为奇数,面值为1的硬币数量为0,那也是无法平均分配的。剩下的情况下就是2的数量为偶数(包括0),1的数量为偶数辣,肯定能平均分。(如果2的数量是偶数1的数量是奇数就无法满足和为偶数了)AC代码:#include <iostream> usin原创 2021-02-05 00:16:09 · 192 阅读 · 0 评论 -
Codeforces Round #693 (Div. 3) A. Cards for Friends(800)
1472 A. Cards for Friends题目大意:已知一张纸在长或者宽为偶数时可以将纸对折一次,纸张数翻倍。现给你一张已知长和宽的纸,并且告诉你目标纸张数,问你能不能实现。AC代码:#include <iostream>#include <cmath> using namespace std; int a,b,n; int main() { int t; cin >> t; while (t--) {原创 2021-02-05 00:07:36 · 128 阅读 · 0 评论 -
Codeforces Global Round 9 D. Replace by MEX(1900)
1375 D. Replace by MEX题目大意:给你一个数列的 mex 的定义:mex = 不存在于该数列中的最小非负数然后进行操作:用这个数列的 mex 替换掉该数列中任何元素最后让输出 操作数 和 每次被替换的序列下标(下标从 1 开始)题目要求:操作数 < 2n题目给出:长度为 n 的初始数列思路分析:这里想法有些偷鸡,我感觉没有 YES 和 NO 的情况下,基本上操作数都能符合题目要求QWQ(后面才知道,替换一个 a[i] = i ,最多需要两次操作)所以我的做法原创 2021-01-27 22:23:12 · 171 阅读 · 0 评论 -
Codeforces Global Round 9 C. Element Extermination(1400)
1375 C. Element Extermination题目大意:给一个数 n,然后给一个数组a,a[i] 包含 1 ~ n 的所有值如果 a[i] < a[i+1],则可以删除 a[i] / a[i+1] 两者中的任意一个问你有没有可能通过这些删除操作使这个数组的长度等于1?也就是最后数组只剩一个元素。思路分析:这题,真的好好想想删除的过程,如果a[0] > a[n-1],则必不可能成立,所以输出 NO其余情况,都可以通过删除操作使长度变为数组长度最后变为 1,输出 YES原创 2021-01-27 22:12:54 · 143 阅读 · 1 评论 -
Codeforces Global Round 9 B. Neighbor Grid(1200)
1375 B. Neighbor Grid题目大意:给你一个矩阵,问这个矩阵能不能变成题目所描述的要求题目要求:初始矩阵中所有元素非负你可以对任意元素 进行任意次 +1 操作如果一个单元格的值 k = 0,则无要求,如果一个单元格的值 k > 0,与其相邻的单元格值 > 0 的个数也要为 k思路分析:先找到不可以的情况,四个角的值要 <= 2,四个边的值要 <= 3,中间的值要 <= 4,如果违反这些的话,直接输出 NO然后我的想法是直接把矩阵填满,就原创 2021-01-27 22:05:29 · 140 阅读 · 0 评论 -
Codeforces Global Round 9 A. Sign Flipping(1100)
1375 A. Sign Flipping题目大意:给一个数组a,你可以翻转其中的任意元素,使得其至少有一半的元素满足a[i] =< a[i + 1],至少有一半满足a[i] >= a[i + 1]。输出最后构造后的新数组。思路分析:只要让数组中一正一负就好了呀,因为题目要求的是相邻元素,所以数组一正一负肯定符合题意AC代码:#include <iostream> using namespace std; const int N = 110; int a原创 2021-01-27 21:55:49 · 127 阅读 · 0 评论 -
Codeforces Round #697 (Div. 3) A. Odd Divisor(900)
Codeforces 1475 A. Odd Divisor题目大意:给你一个数让你判断这个数有没有大于 1 的奇数因子思路分析:首先,如果这个数是奇数的话,一定有大于 1 的奇数因子,即他本身;如果这个数是偶数的话,反正想,如果偶数没有奇数因子,一直除 2 肯定最后结果是 1 并且整除后的结果依然是偶数。AC代码:#include <bits/stdc++.h> #define ll long long using namespace std; ll n; i原创 2021-01-26 23:05:02 · 152 阅读 · 0 评论 -
Codeforces Round #697 (Div. 3) B. New Year‘s Number(900)
Codeforces 1475 B. New Year’s Number题目大意:新年了嘛,2020 && 2021题目的意思是给你个数让你判断这个数是不是能只由2020 / 2021 组成思路分析:诶,这个题就感觉很不错,是和数字有关的,当时的想法就体现在代码里了(可能是直觉QWQ,但后面看一些大佬题解发现思路一样的,还是蛮开心的,一发AC也是意外之喜w)说白了,其实就是计算这个年份对2020的余数,然后和这个年份有几个2020进行比较AC代码:#include &l原创 2021-01-26 22:43:28 · 252 阅读 · 0 评论 -
Codeforces Round #697 (Div. 3) C. Ball in Berland(1400)
Codeforces 1475 C. Ball in Berland题目分析:这个题其实就是给你一堆坐标,让你找到合适的有多少对思路分析:坐标的话,首先想到用 pair<int,int> 和 set 进行存储坐标,然后就是对坐标进行一次遍历,时间复杂度是 O(n)AC代码:#include <iostream>#include <set>#include <cstring> #define PII pair<int,int>原创 2021-01-26 22:19:26 · 241 阅读 · 0 评论 -
Codeforces Round #697 (Div. 3) D. Cleaning the Phone(1800)
Codeforces 1475 D. Cleaning the Phone题目大意:给你三行第一行 n , m:n代表软件数,m代表要清理出来的内存第二行有n个数据,每个数据代表该软件所占用的内存第三行还是n个数据,每个数据代表软件的重要程度,只有1和2,2更重要一点题目要求输出,清理出来m内存的前提下,删去软件重要程度点尽可能小思路分析:上来一看,很快啊,感觉是个贪心,但是感觉处理的条件有点多,这个东西只要想明白了过程还蛮好理解的QWQ。我的想法是:重要程度 1 和 2 软件 分开存原创 2021-01-26 22:32:36 · 214 阅读 · 0 评论 -
Codeforces Round #688 (Div. 2) B.Suffix Operations(1400)
codeforces 1453 B.Suffix Operations思路分析:由于第一次见过这个题,第二次做的时候,思路比较清晰了,这个题也是和数组的前后缀有关系。题目让选择一个进行改变,因此,先分析出一个都不改变的时候,总共需要的步数是多少,然后找出改变哪个影响的步数最大。总步数-影响最大的步数,就是最后的答案。AC代码:#include <bits/stdc++.h>#define ll long longusing namespace std;const in原创 2021-01-23 15:03:20 · 126 阅读 · 0 评论 -
Codeforces Round #688 (Div. 2) A.Cancel the Trains(800)
codeforces 1453 A.思路分析:经典签到题,最后的意思大概是,横纵出发的号一样的话,才会相撞AC代码:#include <bits/stdc++.h> using namespace std; const int N = 110; int a[N]; int main() { int t; cin >> t; while (t--) { int n, m; cin >> n原创 2021-01-23 14:39:31 · 115 阅读 · 0 评论 -
Codeforces Round #689 (Div. 2) C. Random Events(1500)
codeforces 1461 C.(传送门)思路分析:这个题分析完后,是有一个影响位 x 的。可以发现从右往左第一个错误的数 x 的左边的位置的概率是无效的,所以我们只要用 x 以及 x 右边的位置的概率就可以了。如果 x 及 x 右侧的概率中有一个是排序的就可以成功,那么我们只要算每个都不排序的概率, 1 - 这个值 就是答案。如果本身就是排序好的,那么答案就是 1 。AC代码:#include <bits/stdc++.h>#define ll long long原创 2021-01-23 14:30:49 · 166 阅读 · 0 评论 -
Codeforces 1469 B. Red and Blue
Codeforces 1469 B. Red and Blue题意分析:第一遍读题的时候,没看清题,其实给定的 r 和 b 序列的顺序是不能更改的,因此 wa 了一发第二遍读题发现,其实就是分开求 r 和 b 序列的最大前缀和,然后让两个再相加即可AC代码:#include <iostream>#define ll long longusing namespace std;const int N = 110;int a[N],b[N];int main() {原创 2021-01-18 15:18:48 · 303 阅读 · 0 评论 -
Codeforces 1462 A. Favorite Sequence
Codeforces 1462 A. Favorite Sequence思路分析:看着题怪长,其实就是类似与回文字符串,搞一个双指针就好了AC代码:#include <iostream>using namespace std;const int N = 310;int a[N];int main() { int t; cin >> t; while (t--) { int n; cin >>原创 2021-01-17 01:26:17 · 238 阅读 · 0 评论 -
Codeforces 1471 B. Strange List
Codeforces 1471 B. Strange List思路分析:最开始用的队列,结果 test5 报 T 了,所以只能找找规律。。。16可以整除4次x,2只能整除x1次,4能够整除x2次。16 2 4 8 816 2 4 8 8 1 116 2 4 8 8 1 1 2 216 2 4 8 8 1 1 2 2 4 416 2 4 8 8 1 1 2 2 4 4 4 4然后我们就发现:16只能用2次,4只能用1次,而2是阻断操作的原因。关键就来了,我们找到序列中能够对x整除次数cn原创 2021-01-17 01:15:19 · 241 阅读 · 0 评论 -
Codeforces 584 A.Olesya and Rodion
Codeforces 584A A.Olesya and Rodion思路分析:一个小思维题,当 t < 10 时,输出 n 个 t 即可要单独考虑的是 t =10注意一下输出 -1 的特殊情况( n == 1 && t == 10 )AC代码:#include <iostream>using namespace std;int main() { int n,t; while (cin >> n >> t) {原创 2021-01-17 00:24:12 · 190 阅读 · 0 评论 -
Codeforces 1445 B题
codeforces 1455 B2021-01-14 打卡题,随便在codeforces上找了一道B. Jumpstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output题目描述:You are standing on the OX-axis at point 0 and you want to move to an integer point原创 2021-01-14 23:46:55 · 395 阅读 · 0 评论 -
Codeforces 695 div2 A题
Codeforces 695 div2 A题A. Wizard of Orztime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n digital panels placed in a straight line. Each panel can show any digit from 0 to 9. Initially, all原创 2021-01-09 10:04:13 · 1357 阅读 · 0 评论 -
codeforces 1433 A题
codeforces 1433 AA. Boring Apartmentstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output题目描述:There is a building consisting of 10 000 apartments numbered from 1 to 10 000, inclusive.Call an apartmen原创 2020-12-04 10:56:53 · 842 阅读 · 0 评论 -
codeforces 1455 B题
codeforces 1455 BB. Jumpstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output题目描述:You are standing on the OX-axis at point 0 and you want to move to an integer point ????>0.You can make several ju原创 2020-12-04 10:48:19 · 405 阅读 · 0 评论 -
codeforces 1455 A题
codeforces 1455 A题目描述ExampleinputCopy5437998244353100000000712345678901337426966631415outputCopy1291026Note思路分析:就是个纸老虎,简单分析一下,题目大意为- - ->求输入整数的位数。代码实现#include <cstdio>#include <algorithm>#include <cstring>usin原创 2020-12-02 10:40:52 · 177 阅读 · 0 评论 -
codeforces 1445 A题
codeforces 1445 A. Array Rearrangmenttime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard output题目描述:You are given two arrays ???? and ????, each consisting of ???? positive integers, and an integer ????. Ple原创 2020-11-28 15:44:08 · 407 阅读 · 0 评论