Educational Codeforces Round 98 (Rated for Div. 2)
A
如果\(n = m\),答案为\(2 \times n\);如果\(n \ne m\),答案为\(2 \times max(n,m) - 1\)
#include <bits/stdc++.h>
using namespace std;
int n, m;
int main()
{
	int __;
	scanf("%d", &__);
	while(__ -- )
	{
		scanf("%d%d", &n, &m);
		printf("%d\n", 2 * max(n, m) - (m != n));
	}
	return 0;
}
B
\(max(a_i) \times (n - 1) <= sum + ans\) , 并且\((n - 1) \mid (sum + ans)\), \(ans\)如果是负数,转化成模\((n-1)\)意义下的正数即可.
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e5 + 20;
int n, a[N];
int main()
{
	int __;
	scanf("%d", &__);
	while(__ --)
	{
		scanf("%d", &n);
		LL sum = 0, maxn = 0;
		for(int i = 1; i <= n; ++ i)
		{
			scanf("%d", &a[i]);
			sum += a[i];
			maxn = max(maxn, (LL)a[i]);
		}
		LL res = maxn * (n - 1) - sum;
		if(res < 0) res = (res % (n - 1) + (n - 1)) % (n - 1);
		printf("%lld\n", res);
	}
	return 0;
}
C
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 20;
char str[N];
int main()
{
	int __;
	scanf("%d", &__);
	while(__ -- )
	{
		scanf("%s", str);
		int res = 0, a = 0, b = 0;
		for(int i = 0; str[i]; ++ i)
		{
			if(str[i] == '[') a ++;
			if(str[i] == ']' && a) a --, res ++;
			if(str[i] == '(') b ++;
			if(str[i] == ')' && b) b --, res ++;
		}
		printf("%d\n", res);
	}
	return 0;
}
D
预处理fib,求\(2^n\)的逆元即可
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MOD = 998244353;
const int N = 2e5 + 10;
int n, f[N];
int pow_mod(int a, int b, int p)
{
	int res = 1;
	while(b)
	{
		if(b & 1) res = (LL)res * a % p;
		a = (LL)a * a % p;
		b >>= 1;
	}
	return res;
}
int main()
{
	f[1] = f[2] = 1;
	for(int i = 3; i < N; ++ i) f[i] = (f[i - 1] + f[i - 2]) % MOD;
	scanf("%d", &n);
	int res = (LL)f[n] * pow_mod(pow_mod(2, n, MOD), MOD - 2, MOD) % MOD;
	printf("%d\n", res);
	return 0;
}
2020.11.21
Educational Codeforces Round 98 (Rated for Div. 2)的更多相关文章
- Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship
		Problem Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ... 
- Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)
		Problem Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ... 
- Educational Codeforces Round 43 (Rated for Div. 2)
		Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ... 
- Educational Codeforces Round 35 (Rated for Div. 2)
		Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ... 
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings
		Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ... 
- Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes
		Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ... 
- Educational Codeforces Round 63 (Rated for Div. 2) 题解
		Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ... 
- Educational Codeforces Round 39 (Rated for Div. 2) G
		Educational Codeforces Round 39 (Rated for Div. 2) G 题意: 给一个序列\(a_i(1 <= a_i <= 10^{9}),2 < ... 
- Educational Codeforces Round 48 (Rated for Div. 2) CD题解
		Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms 题目链接:https://codeforce ... 
随机推荐
- Python 往Excel写数据
			一.需求描述: 1.一张人员信息表中生成人员信息,某些列的字段要进行递增操作: 2.一个组织节点下存在1000人的限制要求: 3.一张Excel表格生成45000条数据: 二.Excel表格的表头如下 ... 
- 【非原创】codeforces 1070C  Cloud Computing 【线段树&树状数组】
			题目:戳这里 学习博客:戳这里 题意:有很多个活动,每个活动有持续天数,每个活动会在每天提供C个CPU每个CPU价格为P,问需要工作N天,每天需要K个CPU的最少花费. 解题思路:遍历每一天,维护当前 ... 
- Kafka 博文索引
			博文索引 KafkaBroker 简析 KafkaConsumer 简析 KafkaProducer 简析 KafkaMirrorMaker 的不足以及一些改进 Kafka 简介 数据是系统的燃料,系 ... 
- js optional chaining operator
			js optional chaining operator js 可选链 可选链操作符( ?. )允许读取位于连接对象链深处的属性的值,而不必明确验证链中的每个引用是否有效. ?. 操作符的功能类似于 ... 
- npm ci All In One
			npm ci All In One npm 性能优化 npm ci 使用干净的面板安装项目 https://docs.npmjs.com/cli/v6/commands/npm-ci # npm cl ... 
- JavaScript for, for...in, for...of, for-await...of difference All In One
			JavaScript for, for...in, for...of, for-await...of difference All In One for for...in for...of for-a ... 
- CSS 设置多行文本省略号 ...
			CSS 设置多行文本省略号 ... .box{ display: -webkit-box; overflow: hidden; text-overflow: ellipsis; word-wrap: ... 
- 微信公众号 bug
			微信公众号 bug web bug refs xgqfrms 2012-2020 www.cnblogs.com 发布文章使用:只允许注册用户才可以访问! 
- js 斩掉单行注释和多行注释
			var json = ` // e { /* hello */ name:/* a */ 'ajanuw' // c /** * * hello * ? adsd * todo */ // c } ` ... 
- 2018-1-6-IDEA快速代码生成
			2018-1-6-IDEA快速代码生成 Java 自动生成 Intellij IDEA 利用IDEA编辑器的Live Templates可以实现自定义方法.属性.注释等,下面是我自己的常用模板. 属性 ... 
