题目来源

Educational Codeforces Round 102 (Rated for Div. 2)

A. Replacing Elements

只要判断最大值是否小于等于d,或者第一个值加第二个值小于等于d即可。

#include<bits/stdc++.h>
using namespace std;#define _for(i, a, b) for (int i = (a); i < (b); ++i)
const int N = 110;
int a[N];int main()
{int T;scanf("%d", &T);while (T--){int n, d;scanf("%d%d", &n, &d);_for(i, 0, n) scanf("%d", &a[i]);sort(a, a + n);printf("%s\n", a[n - 1] <= d || a[0] + a[1] <= d ? "YES" : "NO");}return 0;
}

B. String LCM

思维题
如果两个字符串之前存在公共子串的话,那么他们长度的最大公约数也是也是一样的。

#include<bits/stdc++.h>
using namespace std;string a, b;int gcd(int a, int b)
{return b ? gcd(b, a % b) : a;
}string repeat(string& s, int n)
{string t;while (n--) t += s;return t;
}int main()
{int T;scanf("%d", &T);while (T--){cin >> a >> b;int d = gcd(a.size(), b.size());string c[] = { repeat(a, b.size() / d), repeat(b, a.size() / d) };cout << (c[0] == c[1] ? c[0] : "-1") << endl;}return 0;
}

C No More Inversions

这题转了怎么大个弯,就是要你求出在1~k的全排列中逆序数和a数组一样多且字典数最大的数组p,所以直接构造就好了,把数组a中k ~ n-(n - k)做p的后部分,a中剩下的没有重复的数字做p的前部分。

#include<bits/stdc++.h>
using namespace std;#define _for(i, a, b) for (int i = (a); i < (b); ++i)
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)int main()
{#ifdef LOCALfreopen("data.in", "r", stdin);
#endif int T;scanf("%d", &T);while (T--){int n, k;scanf("%d%d", &n, &k);_for (i, 1, 2 * k - n) printf("%d ", i);_rep(i, 0, n - k) printf("%d ", k - i);puts("");}return 0;
}

【CF比赛】Educational Codeforces Round 102 (Rated for Div. 2)相关推荐

  1. Educational Codeforces Round 114 (Rated for Div. 2) (A ~ F)全题解

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Educational Codeforces Round 114 (Rated for Div. 2) ...

  2. Educational Codeforces Round 89 (Rated for Div. 2)(A, B, C, D)

    Educational Codeforces Round 89 (Rated for Div. 2) A. Shovels and Swords 思路 题意非常简单,就是得到最多的物品嘛,我们假定a, ...

  3. Educational Codeforces Round 104 (Rated for Div. 2)A~E解题报告

    Educational Codeforces Round 104 (Rated for Div. 2) A. Arena \quad原题链接 http://codeforces.com/contest ...

  4. Educational Codeforces Round 61 (Rated for Div. 2)(A、B、C、D、E、F)

    欢迎访问本菜鸡的独立博客:Codecho 比赛名称 Educational Codeforces Round 61 (Rated for Div. 2) 比赛链接 https://codeforces ...

  5. Educational Codeforces Round 86 (Rated for Div. 2) Apr/26/2020 22:35UTC+8

    Educational Codeforces Round 86 Rated for Div. 2 A. Road To Zero B. Binary Period(找最小周期) C. Yet Anot ...

  6. A、B、C、D、Educational Codeforces Round 42 (Rated for Div. 2)

    Educational Codeforces Round 42 (Rated for Div. 2)  http://codeforces.com/contest/962 A:Equator 这里需要 ...

  7. Educational Codeforces Round 138 (Rated for Div. 2)-赛后总结

    Dashboard - Educational Codeforces Round 138 (Rated for Div. 2) - Codeforces 总结一个教训就是不要心急,特别是对于一些题目, ...

  8. Educational Codeforces Round 138 (Rated for Div. 2) D

    Educational Codeforces Round 138 (Rated for Div. 2) D. Counting Arrays 题意 给定长度为nnn的数组aaa,若gcd(ai,i)= ...

  9. Educational Codeforces Round 138 (Rated for Div. 2) A~D

    比赛链接:Dashboard - Educational Codeforces Round 138 (Rated for Div. 2) - Codeforces 目录 A. Cowardly Roo ...

最新文章

  1. [转]VS2015编译的程序在其他机器上缺少msvcp120.dll
  2. LeetCode - Department Highest Salary
  3. 【NLP】 NLP中应用最广泛的特征抽取模型-LSTM
  4. [转]Could not load file or assembly 'XXX' or one of its dependencies.
  5. Ubuntu宿主机与VMware中其他系统虚拟机的互通
  6. Anaconda日志
  7. 字段连接select语句
  8. 2021-08-24梦笔记
  9. 遗传算法在TSP中的应用
  10. 一步一步超级详细的zabbix安装教程
  11. java打印字符串_Java 打印字符串
  12. 基于wifi的温度采集与控制系统
  13. c语言编程 模拟掷骰子,用C语言编写一个模拟掷骰子游戏
  14. 不能装载文档控件。请在检查浏览器的选项中检查浏览器的安全设置_「初级会计报考指南」浏览器问题解决方案...
  15. 漫谈测试成长之探索——测试用例评审
  16. 【4G5G基础学习】物理层-物理随机接入信道PRACH与随机接入过程
  17. python3识别简单验证码
  18. BZOJ4605 : 崂山白花蛇草水
  19. 蓝桥杯 基础练习VIP FJ的字符串 java
  20. 使用stm32cubeIDE建立USB HOST工程读取大容量U盘(MSC类库)

热门文章

  1. 大厂机密,30 提升团队研发效能的锦囊
  2. mysql的sql语言学习笔记总结
  3. 亚马逊erp系统亚马逊FBA系统货代仓储打包系统
  4. JavaWeb搭建简易个人博客
  5. UML类图简介及类与类之间的关系
  6. 【解惑】专科生在IT的发展之路
  7. cin.tie(NULL)--加速
  8. Ghost的一些使用方法
  9. Java并发编程与技术内幕:ConcurrentHashMap源码解析
  10. java.io.IOException: java.io.FileNotFoundException: XXX(系统找不到指定的路径)