Codeforces Round #553 (Div. 2) 题解

ArcGIS License Server点击启动没反应,许可管理器无法启动怎么办 4 当我们再打开ArcGIS License Server Administrator的时候。3 在【服务】中找到【ArcGIS License Manager】双击。无法启动ArcGIS License Server的情况。在使用ArcGIS的过程中,我们经常会遇到。专注GIS领域知识分享,交流行业软件技巧。欢迎关注,不定期分享GIS各种问题和技巧。1 右击我的电脑——【管理】服务状态——启动,确定即可。启动类型选择——自动。 阅读详情

题目链接

A. Maxim and Biology

取连续一段改为ACTG的最小代价

#include <stdio.h>
#include <bits/stdc++.h>
#define fst first
#define sed second
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
char s[100], c[] = "ACTG";

int dis(char a, char b)
{
	a = a - 'A', b = b - 'A';
	return min((a - b + 26) % 26, (b - a + 26) % 26);
}
int main()
{
#ifdef LOCAL
	//freopen("C:/input.txt", "r", stdin);
#endif
	int n;
	cin >> n >> s;
	int ans = INF;
	for (int i = 0; i < n - 3; ++i)
	{
		int cnt = 0;
		for (int j = 0; j < 4; ++j)
			cnt += dis(s[i + j], c[j]);
		ans = min(ans, cnt);
	}
	cout << ans << endl;

	return 0;
}

B. Dima and a Bad XOR <思维>

矩阵每行选一个数字异或和不为0

#include <stdio.h>
#include <bits/stdc++.h>
#define fst first
#define sed second
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int N = 510;
int g[N][N];

int main()
{
#ifdef LOCAL
	//freopen("C:/input.txt", "r", stdin);
#endif
	int n, m, x = 0;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = 1; j <= m; ++j)
			scanf("%d", &g[i][j]);
		x ^= g[i][1];
	}
	if (x)
	{
		cout << "TAK" << endl;
		for (int i = 1; i <= n; ++i)
			cout << "1 ";
		cout << endl, exit(0);
	}
	for (int i = 1; i <= n; ++i)
		for (int j = 2; j <= m; ++j)
		{
			x ^= g[i][j - 1] ^ g[i][j];
			if (x)
			{
				cout << "TAK" << endl;
				for (int k = 1; k < i; ++k)
					cout << "1 ";
				cout << j << " ";
				for (int k = i + 1; k <= n; ++k)
					cout << "1 ";
				cout << endl, exit(0);
			}
		}
	cout << "NIE" << endl;

	return 0;
}

C. Problem for Nazar <模拟> <复杂度分析>

给定一个序列1/2 4/3 5 7 9/6 8 10。。奇数偶数交替且长度增加一倍 问第l到r项的和

#include <stdio.h>
#include <bits/stdc++.h>
#define fst first
#define sed second
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;

ll calc(ll x) //logn计算1~x项和
{
	ll res = 0;
	ll v[2] = { 2, 1 }, w = 1; //奇偶当前数值 项数
	for (int i = 1; x; i = (i + 1) % 2, w *= 2)
	{
		res = (res + (v[i] + v[i] + (min(x, w) - 1) * 2LL) % MOD * (min(x, w) % MOD) % MOD * 500000004LL) % MOD; //等差数列求和 除法逆元注意炸ll
		v[i] = (v[i] + w * 2LL) % MOD;
		x -= min(x, w);
	}
	return res;
}
int main()
{
#ifdef LOCAL
	//freopen("C:/input.txt", "r", stdin);
#endif
	ll l, r;
	cin >> l >> r;
	cout << (calc(r) - calc(l - 1) + MOD) % MOD << endl;

	return 0;
}

D. Stas and the Queue at the Buffet <贪心>

每个人有两个参数a和b 这个人的不满意度为他前面人数量a+后面人数量b 问整个队列最小不满意度

#include <stdio.h>
#include <bits/stdc++.h>
#define fst first
#define sed second
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int N = 1e5 + 10;

struct node
{
	ll a, b, i;
	bool operator < (const node &o) const
	{
		return a - b > o.a - o.b;
	}
}a[N];
int main()
{
#ifdef LOCAL
	//freopen("C:/input.txt", "r", stdin);
#endif
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)
		scanf("%I64d%I64d", &a[i].a, &a[i].b), a[i].i = i;
	sort(a + 1, a + n + 1);
	ll ans = 0;
	for (int i = 1; i <= n; ++i)
		ans += a[i].a * (i - 1) + a[i].b * (n - i);
	cout << ans << endl;

	return 0;
}

E. Number of Components <贡献>

给n个数字 位置相邻的两个数字之间有一条连线 f(l,r)表示只保留数值范围[l,r]节点的强连通分量数 函数f(1<=l<=r<=n)所有取值的和
计算每个点产生贡献的区间[l, r],如当前点值为a[i]则1<=l<=a[i]<=r<=n,但是如果左侧的点存在l和r的取值范围就会有些限制。
调整lr后,l和r的取值范围相乘就是当前点的贡献。

#include <stdio.h>
#include <bits/stdc++.h>
#define fst first
#define sed second
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int N = 1e5 + 10;
ll a[N];

int main()
{
#ifdef LOCAL
	//freopen("C:/input.txt", "r", stdin);
#endif
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)
		scanf("%I64d", &a[i]);
	ll ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		ll l = a[i], r = n - a[i] + 1;
		if (a[i - 1] <= a[i])
			l = min(l, a[i] - a[i - 1]);
		else
			r = min(r, a[i - 1] - a[i]);
		ans += l * r;
	}
	cout << ans << endl;

	return 0;
}

F. Sonya and Informatics <dp> <矩阵优化> <组合数>

一个01串等概率随机选取两个不同的位置进行交换 k次操作后问串为非递减序列的概率
参考大佬博客

#include <stdio.h>
#include <bits/stdc++.h>
#define fst first
#define sed second
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;
const int N = 110;
int C[N][N];
int a[N];
//ll f[N][N]; //f[i][j]表示i次操作j个0不在应该在的位置上

ll qpow(ll a, ll n, ll m)
{
	ll res = 1;
	while (n)
	{
		if (n & 1)
			res = res * a % m;
		a = a * a % m;
		n >>= 1;
	}
	return res;
}
struct Matrix
{
	ll m[N][N];
	static const int N = 50; //阶数
	Matrix(int v = 0)
	{
		memset(m, 0, sizeof(m));
		if (v)
			for (int i = 0; i < N; i++)
				m[i][i] = v;
	}
	Matrix operator * (const Matrix &b)
	{
		Matrix t;
		for (int i = 0; i < N; i++)
			for (int j = 0; j < N; j++)
				for (int k = 0; k < N; k++)
					t.m[i][j] = (t.m[i][j] + m[i][k] * b.m[k][j]) % MOD;
		return t;
	}
	friend Matrix operator ^ (Matrix a, int n)
	{
		Matrix t(1);
		while (n)
		{
			if (n & 1)
				t = t * a;
			a = a * a;
			n >>= 1;
		}
		return t;
	}
}tran, x; //x[0][i]表示当前状态有i个0/1不在应该在的位置上
int main()
{
#ifdef LOCAL
	freopen("C:/input.txt", "r", stdin);
#endif
	C[0][0] = 1;
	for (int i = 1; i < N; i++)
	{
		C[i][0] = 1;
		for (int j = 1; j < N; j++)
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;
	}
	int n, k, z = 0; //0个数
	cin >> n >> k; 
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]), z += !a[i];
	int p = 0; //位置不对的个数 位置不对的1=位置不对的0
	for (int i = 1; i <= z; ++i)
		p += a[i];
	/*
	f[0][p] = 1;
	int m = min(z, n - z), den = qpow(C[n][2], MOD - 2, MOD); //den总情况
	for (int i = 0; i < k; ++i) //操作
		for (int j = 0; j <= m; ++j) //不对的数量不会超过某个的数量
		{
			if (j) //交换后位置不对数量-1
				f[i + 1][j - 1] = (f[i + 1][j - 1] + f[i][j] * j * j * den) % MOD; //0不对*1不对
			if (j < m) //数量+1
				f[i + 1][j + 1] = (f[i + 1][j + 1] + f[i][j] * (z - j) * (n - z - j) * den) % MOD; //0对*1对
			f[i + 1][j] = (f[i + 1][j] + f[i][j] * (C[z][2] + C[n - z][2] + (z - j) * j + (n - z - j) * j) * den) % MOD;
		}
	cout << f[k][0] << endl;
	*/
	x.m[0][p] = 1; //初始状态100%
	ll m = min(z, n - z), den = qpow(C[n][2], MOD - 2, MOD); //den总情况
	for (int i = 0; i <= m; ++i) //不对的数量 不会超过某个的数量
	{
		int j;
		if (i) //由i-1增加1个转移来
		{
			j = i - 1; //上个状态
			tran.m[i - 1][i] = (z - j) * (n - z - j) * den % MOD; //0对*1对
		}
		tran.m[i][i] = (C[z][2] + C[n - z][2] + (z - i) * i + (n - z - i) * i) * den % MOD; //0/1交换 同侧01/10交换
		if (i < m) //由i+1减少1个转移来
		{
			j = i + 1;
			tran.m[i + 1][i] = j * j * den % MOD; //0不对*1不对
		}
	}
	x = x * (tran ^ k);
	cout << x.m[0][0] << endl; //输出全对情况

	return 0;
}
深入解析“PROJ: proj_create_from_database: Cannot find proj.db”错误:从环境配置到打包实战 本文深入解析了“PROJ: proj_create_from_database: Cannot find proj.db”错误的根源与解决方案,涵盖环境配置、PyInstaller打包及跨平台兼容性处理。通过详细分析PROJ库路径问题及GDAL依赖关系,提供动态路径设置、资源文件打包等实战技巧,帮助开发者高效解决地理数据处理中的常见错误。 阅读详情

相关推荐

NVIDIA DGX Spark实战:如何在桌面上轻松运行200B参数大模型?

本文详细介绍了如何利用NVIDIA DGX Spark在桌面端轻松运行200B参数大模型。通过实战演示,从系统初始化、模型获取部署到内存管理与性能调优,重点解析了其统一内存架构如何解决本地推理的显存瓶颈,并探讨了进行轻量化微调(如LoRA)的可能性,为AI开发者和研究团队提供了高效的本地化大模型操作方案。

weixin_29054195的博客 886

Codeforces Round #553 (Div2)

Codeforces Round #553 (Div. 2) ABCD题解 A. Maxim and Biology 思路:暴力即可 #include<bits/stdc++.h> using namespace std; const int inf=0x3f3f3f3f; const int MAXN=1e5+10; int MAX=1e5+1; char cc[]="ACTG"; ...

Dch19990825的博客 357

用Omniverse Kit开发第一个USD插件:从环境配置到实战案例(Python 3.7版)

本文详细介绍了如何使用NVIDIA Omniverse Kit和Python 3.7开发第一个USD插件,涵盖从环境配置到实战案例的全过程。通过创建可实时同步材质属性的USD插件,开发者可以快速掌握Omniverse开发框架,提升3D内容创作效率。

x8y9z0的博客 588

CodeforcesRound#553(Div. 2)(A-D题解)

http://codeforces.com/contest/1151/problem/A 题意:对于任意两个字符a,b,将a变成b的价值为他们的最小距离。其中z到a的距离是1。    求出将给定字符串变成一个含有 "ACTG" 子串的字符串最小价值。 思路:暴力模拟。 1 #include <bits/stdc++.h> 2 using namespac...

a15288862893的博客 247

基于浏览器插件的拼多多买家订单导出方法

基于浏览器插件的拼多多买家订单导出方法

2501_93542170的博客 1731

诠视MR眼镜Unity开发设置_Unity2020.3.38

请按照如下设置Android SDK 和 Gradle。打包前先将Unity切换到Android模式。Preferences 设置。

m0_71932574的博客 603

Codeforces Round #553 (Div. 2)

A. Maxim and Biology time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Today in the scientific lyceum of the Kingdom of Kremland, th...

Minoz的博客 563

某盾blackBox逆向——纯算

某盾blackBox逆向——纯算

Lzyydsb的博客 5893

Codeforces Round #553 (Div. 2) Solution

Codeforces Round #553 (Div. 2) Solution 今天早上开的一把\(\rm vp\),前四题很水,看了\(\rm E,F\)之后我去写了\(\rm F\),然后还没调出来血亏...赛后才发现\(\rm E\)是真的水... 比赛传送门:https://codeforces.com/contest/1151 A. Maxim and Biology https://...

weixin_30487317的博客 143

手把手教你学Simulink--基于电能质量与无功补偿的场景实例:统一电能质量调节器(UPQC)的联合控制仿真

在现代电力系统中,电能质量问题有源电力滤波器(APF)→ 治理谐波与无功动态电压恢复器(DVR)→ 补偿电压暂降/暂升静止无功发生器(SVG)→ 无功补偿与电压支撑而统一电能质量调节器(Unified Power Quality Conditioner, UPQC)是一种集串联补偿与并联补偿于一体的全能型电能质量治理装置✅ 电压类问题:暂降、暂升、不平衡、闪变✅ 电流类问题:谐波、无功、三相不平衡✅ 实现双向有功交换(储能型)串联单元(DVR功能):串联于线路,控制电源侧电压质量并联单元。

MHD0815的博客 240

Hermes 教程 03:Skills 系统

摘要:Hermes Skills是一种自我改进机制,可将解决问题的经验保存为可复用技能文档。v0.13.0版本遵循agentskills.io开放标准,与Claude Skills互通。技能创建流程包括发现问题、创建技能文件、加载使用和优化更新四个阶段。系统提供技能检索和自维护机制(Curator),支持技能媒体路由和多种管理命令。内置技能涵盖开发调试、创意头脑风暴等场景,通过积累技能使Hermes更适应用户需求。

程序猿_三产 733

Codeforces Round #553 (Div. 2) 1151D Stas and the Queue at the Buffet

Codeforces Round #553 (Div. 2) 1151D Stas and the Queue at the Buffet 水题翻车留念(于2019/10/08的练习) Problem Description During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, the...

BenFromHRBUST的优快云博客 294

ROS & ROS2 机器人深度相机激光雷达多传感器标定工具箱入门教程(一)

multisensor_calibration 是一个积极维护的通用标定工具箱,用于辅助基于目标的多传感器标定,支持 ROS 1 和 ROS 2。它提供了多种方法和应用来标定复杂的多传感器系统,例如。

2506_90492529的博客 3261

Codeforces Round #553 div.2

题目链接:戳我 好久没有写CF了(实际上好久没有动脑子了),实在是惨淡至极。这几天打算每天都开virtual contest qwq...... A 注意情况的分类讨论qwq #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include&...

weixin_30781433的博客 98

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

Codeforces Round #553 (Div. 2) A-E

A:http://codeforces.com/contest/1151/problem/A 枚举每4个 求变成ACTG的最小次数 #include <bits/stdc++.h> const int M = 100000+100; using namespace std; char q[5]={' ','A','C','T','G'}; int ab(int a) { if...

bjfu170203101的博客 165

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

CodeForces Round #553 Div2

A. Maxim and Biology 代码: #include <bits/stdc++.h> using namespace std; int N; string s; int minn = 0x3f3f3f3f; int main() { scanf("%d", &N); cin >> s; for...

weixin_30291791的博客 84

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

上一篇: Codeforces Round #552 (Div. 3) 题解
下一篇: 河南省第九届ACM程序设计竞赛 部分题解
CaprYang
博客等级 码龄8年 147粉丝 277原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值