进阶数据结构——高精度运算

目录

  • 前言
  • 一、高精度运算的定义与背景
  • 二、高精度运算的实现方式
  • 三、高精度运算的算法实现
  • 四、高精度运算的应用场景
  • 五、代码模版(c++)
  • 六、经典例题
    • 1.[高精度加法](https://www.lanqiao.cn/problems/1516/learning/?page=1&first_category_id=1&name=%E9%AB%98%E7%B2%BE%E5%BA%A6%E5%8A%A0%E6%B3%95)
    • 3.[高精度减法](https://www.luogu.com.cn/problem/P2142)
    • 3.[高精度乘法](https://www.lanqiao.cn/problems/1515/learning/?page=1&first_category_id=1&name=%E9%98%B6%E4%B9%98%E8%AE%A1%E7%AE%97)
    • 4.[高精度除法](https://www.luogu.com.cn/problem/P1480)
  • 七、总结
  • 结语

前言

从这期开始我们就开始进入进阶数据结构的学习了。进阶数据结构中的高精度运算分析,主要聚焦于如何在计算机编程中有效处理超出常规数据类型表示范围的极大或极精确数值。

在这里插入图片描述

一、高精度运算的定义与背景

高精度运算是指在计算机编程中,对超出常规数据类型(如整型、浮点型)所能表示范围的极大或极精确数值进行的各种数学运算。在标准的计算机编程语言中,内置的整数和浮点数类型有其固定的字节数和精度限制,一旦数字过大或精度过高,就会导致溢出或精度丢失的问题。因此,高精度运算技术应运而生。

二、高精度运算的实现方式

高精度运算的实现方式通常涉及自定义数据结构来存储极大数值的每一位。这些数据结构能够模拟人类手算时多位数列的运算规则,使得在理论上能够处理任意长度和精度的数字。常见的实现方式包括:
数组:数组是最常用的数据结构之一,在高精度运算中,可以使用数组来存储每一位数字。例如,在C++中,可以使用std::vector或std::deque等动态数组来分别存储每一位数字。这种方式的好处是访问和修改数字的各个位非常方便,且能够处理任意长度的数字。
字符串:在某些情况下,也可以使用字符串来表示高精度数。字符串的好处是能够直接输入和输出,且不需要考虑数字的位数和进位问题。但是,字符串中的每一位是一个字符,不能直接进行运算,必须先将它转化为数值再进行运算,这增加了运算的复杂性。

三、高精度运算的算法实现

高精度运算的算法实现包括加、减、乘、除等基本运算。以下是对这些运算的简要分析:

加法:高精度加法的基本思想是将两个加数和被加数数组从第一位开始对其,并从第一位开始向后遍历,每一位相加并判断进位,直至到达输入数据末端为止。最后,如果最高位有进位,则需要添加一位。
减法:高精度减法与加法类似,但需要注意处理借位问题。当被减数小于减数时,需要向前一位借位。借位的过程可以通过在该位加上10并减去下一位的值来实现。同时,需要注意处理结果的符号和前导零。
乘法:高精度乘法的基本思想是两个数组相对应位置的数字相乘并考虑进位。可以使用双重循环来遍历两个数组的每一位,并将乘积累加到结果数组中。最后,需要处理进位问题。
除法:高精度除法相对复杂,通常使用长除法或更高效的算法如Karatsuba算法等来实现。除法的关键是逐位确定商的值,并通过减法来确定余数。由于除法运算的复杂性,实现时需要注意处理各种边界情况和异常情况。

四、高精度运算的应用场景

高精度运算在许多领域都有广泛的应用场景,包括但不限于:

科学计算:在科学计算中,经常需要处理小数点后几百位甚至更多的数字,高精度运算能够提供必要的精度和范围支持。
金融计算:在金融领域,高精度运算用于处理大额货币交易和精确计算利息等金融指标。
密码学:在密码学中,高精度运算用于实现加密算法和生成大素数等安全操作。
计算机图形学:在计算机图形学中,高精度运算用于处理浮点数运算中的精度丢失问题,以确保图形的精确渲染。

五、代码模版(c++)

六、经典例题

1.高精度加法

蓝色字体点进去看原题
蓝色字体点进去看原题
蓝色字体点进去看原题

#include<iostream>
#include<cstring>
using namespace std;

const int Base = 1000;			//进制数
const int Capacity = 100;		//数组容量

class BigInt {
private:
	int m_size;
	int m_data[Capacity];

	void removeLendingZero();				//去除前导0
public:
	BigInt(int v);				
	BigInt();								
	BigInt(char s[]);						//将数字字符串存入数据
	void print(char end);
	BigInt(const BigInt& bi);
	BigInt& operator=(const BigInt& bi);
	int compare(const BigInt& bi);

	BigInt operator+(const BigInt& bi);
	BigInt operator-(const BigInt& bi);
	BigInt operator*(const BigInt& bi);
	BigInt operator/(const BigInt& bi);
};

BigInt::BigInt() {
	m_size = 0;
	memset(m_data, 0, sizeof(m_data));
}

BigInt::BigInt(int v) {
	m_size = 0;
	while (v > 0) {
		m_data[m_size++] = v % Base;
		v /= Base;
	}
}

BigInt::BigInt(char s[]) {
	m_size = 0;
	int b = 1;
	memset(m_data, 0, sizeof(m_data));
	for (int i = strlen(s) - 1; i >= 0; i--) {
		m_data[m_size] += (s[i] - '0') * b;
		b *= 10;
		if (b >= Base) {
			b = 1;
			m_size++;
			m_data[m_size] = 0;
		}
	}
	if (m_data[m_size] > 0) m_size++;
	removeLendingZero();
}

BigInt::BigInt(const BigInt& bi) {
	m_size = bi.m_size;
	memcpy(m_data, bi.m_data, sizeof(bi.m_data));
}

BigInt& BigInt::operator=(const BigInt& bi) {
	m_size = bi.m_size;
	memcpy(m_data, bi.m_data, sizeof(m_data));
	return *this;
}

void BigInt::print(char end) {
	cout << (m_size == 0 ? 0 : m_data[m_size - 1]);
	for (int i = m_size - 2; i >= 0; i--) {
		for (int j = Base / 10; j > 0; j /= 10) {
			cout << (m_data[i] / j) % 10;
		}
	}
	cout << end;
}

void BigInt::removeLendingZero() {
	while (m_size > 0 && m_data[m_size - 1] == 0) {
		m_size--;
	}
}

int BigInt::compare(const BigInt& bi) {
	if (m_size != bi.m_size)return m_size > bi.m_size ? 1 : -1;
	for (int i = m_size - 1; i >= 0; i--) {
		if (m_data[i] != bi.m_data[i]) return m_data[i] > bi.m_data[i] ? 1 : -1;
	}
	return 0;
}

BigInt BigInt::operator+(const BigInt& bi) {
	BigInt ret;
	int carry = 0, i;
	for (i = 0; i < bi.m_size || i < m_size || carry > 0 ; i++) {
		/*if (i < m_size)*/carry += m_data[i];
		/*if (i < bi.m_size)*/carry += bi.m_data[i];
		ret.m_data[i] = carry % Base;
		carry /= Base;
	}
	ret.m_size = i;		//注意此时ret的长度就是为i
	return ret;
}

int main() {
	char s1[1000], s2[1000];
	while (cin >> s1 >> s2) {
		BigInt a(s1), b(s2);
		(a + b).print('\n');
	}


	return 0;
}

3.高精度减法

这一题你们要注意范围长度,还要处理负数的情况

#include<iostream>
#include<cstring>
using namespace std;

const int Base = 1000;			//进制数
const int Capacity = 10086 / 3 + 1;		//数组容量

class BigInt {
private:
	int m_size;
	int m_data[Capacity];

	void removeLendingZero();				//去除前导0
public:
	BigInt(int v);				
	BigInt();								
	BigInt(char s[]);						//将数字字符串存入数据
	void print(char end);
	BigInt(const BigInt& bi);
	BigInt& operator=(const BigInt& bi);
	int compare(const BigInt& bi);

	BigInt operator+(const BigInt& bi);
	BigInt operator-(const BigInt& bi);
	BigInt operator*(const BigInt& bi);
	BigInt operator/(const BigInt& bi);
};

BigInt::BigInt() {
	m_size = 0;
	memset(m_data, 0, sizeof(m_data));
}

BigInt::BigInt(int v) {
	m_size = 0;
	while (v > 0) {
		m_data[m_size++] = v % Base;
		v /= Base;
	}
}

BigInt::BigInt(char s[]) {
	m_size = 0;
	int b = 1;
	memset(m_data, 0, sizeof(m_data));
	for (int i = strlen(s) - 1; i >= 0; i--) {
		m_data[m_size] += (s[i] - '0') * b;
		b *= 10;
		if (b >= Base) {
			b = 1;
			m_size++;
			m_data[m_size] = 0;
		}
	}
	if (m_data[m_size] > 0) m_size++;
	removeLendingZero();
}

BigInt::BigInt(const BigInt& bi) {
	m_size = bi.m_size;
	memcpy(m_data, bi.m_data, sizeof(bi.m_data));
}

BigInt& BigInt::operator=(const BigInt& bi) {
	m_size = bi.m_size;
	memcpy(m_data, bi.m_data, sizeof(m_data));
	return *this;
}

void BigInt::print(char end) {
	cout << (m_size == 0 ? 0 : m_data[m_size - 1]);
	for (int i = m_size - 2; i >= 0; i--) {
		for (int j = Base / 10; j > 0; j /= 10) {
			cout << (m_data[i] / j) % 10;
		}
	}
	cout << end;
}

void BigInt::removeLendingZero() {
	while (m_size > 0 && m_data[m_size - 1] == 0) {
		m_size--;
	}
}

int BigInt::compare(const BigInt& bi) {
	if (m_size != bi.m_size)return m_size > bi.m_size ? 1 : -1;
	for (int i = m_size - 1; i >= 0; i--) {
		if (m_data[i] != bi.m_data[i]) return m_data[i] > bi.m_data[i] ? 1 : -1;
	}
	return 0;
}

BigInt BigInt::operator+(const BigInt& bi) {
	BigInt ret;
	int carry = 0, i;
	for (i = 0; i < bi.m_size || i < m_size || carry > 0 ; i++) {
		/*if (i < m_size)*/carry += m_data[i];
		/*if (i < bi.m_size)*/carry += bi.m_data[i];
		ret.m_data[i] = carry % Base;
		carry /= Base;
	}
	ret.m_size = i;		//注意此时ret的长度就是为i
	return ret;
}

BigInt BigInt::operator-(const BigInt& bi) {
	BigInt ret;
	int carry = 0;
	ret.m_size = m_size;
	for (int i = 0; i < m_size; i++) {
		ret.m_data[i] = m_data[i] - carry;
		if (i < bi.m_size) ret.m_data[i] -= bi.m_data[i];	//一定是判断减数的每一位减完了没有,如果没有结果值为乱数
		if (ret.m_data[i] < 0) {
			ret.m_data[i] += Base;
			carry = 1;
		}
		else carry = 0;		//注意carry一定要重新赋值为0,不然到下一位的时候carry的值就被污染了
	}

	ret.removeLendingZero();
	return ret;
}



int main() {
	char s1[100087], s2[100087];
	while (cin >> s1 >> s2) {
		BigInt a(s1), b(s2);
		if (a.compare(b) >= 0) (a - b).print('\n');
		else {
			cout << "-";
			(b - a).print('\n');
		}
	}


	return 0;
}

3.高精度乘法

#include<iostream>
#include<cstring>
using namespace std;

const int Base = 1000;			//进制数
const int Capacity = 1000;		//数组容量

class BigInt {
private:
	int m_size;
	int m_data[Capacity];

	void removeLendingZero();				//去除前导0
public:
	BigInt(int v);				
	BigInt();								
	BigInt(char s[]);						//将数字字符串存入数据
	void print(char end);
	BigInt(const BigInt& bi);
	BigInt& operator=(const BigInt& bi);
	int compare(const BigInt& bi);

	BigInt operator+(const BigInt& bi) const;
	BigInt operator-(const BigInt& bi) const;
	BigInt operator*(const BigInt& bi) const;
	BigInt operator/(const BigInt& bi) const;
};

BigInt::BigInt() {
	m_size = 0;
	memset(m_data, 0, sizeof(m_data));
}

BigInt::BigInt(int v) {
	m_size = 0;
	while (v > 0) {
		m_data[m_size++] = v % Base;
		v /= Base;
	}
}

BigInt::BigInt(char s[]) {
	m_size = 0;
	int b = 1;
	memset(m_data, 0, sizeof(m_data));
	for (int i = strlen(s) - 1; i >= 0; i--) {
		m_data[m_size] += (s[i] - '0') * b;
		b *= 10;
		if (b >= Base) {
			b = 1;
			m_size++;
			m_data[m_size] = 0;
		}
	}
	if (m_data[m_size] > 0) m_size++;
	removeLendingZero();
}

BigInt::BigInt(const BigInt& bi) {
	m_size = bi.m_size;
	memcpy(m_data, bi.m_data, sizeof(bi.m_data));
}

BigInt& BigInt::operator=(const BigInt& bi) {
	m_size = bi.m_size;
	memcpy(m_data, bi.m_data, sizeof(m_data));
	return *this;
}

void BigInt::print(char end) {
	cout << (m_size == 0 ? 0 : m_data[m_size - 1]);
	for (int i = m_size - 2; i >= 0; i--) {
		for (int j = Base / 10; j > 0; j /= 10) {
			cout << (m_data[i] / j) % 10;
		}
	}
	cout << end;
}

void BigInt::removeLendingZero() {
	while (m_size > 0 && m_data[m_size - 1] == 0) {
		m_size--;
	}
}

int BigInt::compare(const BigInt& bi) {
	if (m_size != bi.m_size)return m_size > bi.m_size ? 1 : -1;
	for (int i = m_size - 1; i >= 0; i--) {
		if (m_data[i] != bi.m_data[i]) return m_data[i] > bi.m_data[i] ? 1 : -1;
	}
	return 0;
}

BigInt BigInt::operator+(const BigInt& bi) const {
	BigInt ret;
	int carry = 0, i;
	for (i = 0; i < bi.m_size || i < m_size || carry > 0 ; i++) {
		if (i < m_size)carry += m_data[i];
		if (i < bi.m_size)carry += bi.m_data[i];
		ret.m_data[i] = carry % Base;
		carry /= Base;
	}
	ret.m_size = i;		//注意此时ret的长度就是为i
	return ret;
}

BigInt BigInt::operator-(const BigInt& bi) const {
	BigInt ret;
	int carry = 0;
	ret.m_size = m_size;
	for (int i = 0; i < m_size; i++) {
		ret.m_data[i] = m_data[i] - carry;
		if (i < bi.m_size) ret.m_data[i] -= bi.m_data[i];	//一定是判断减数的每一位减完了没有,如果没有结果值为乱数
		if (ret.m_data[i] < 0) {
			ret.m_data[i] += Base;
			carry = 1;
		}
		else carry = 0;		//注意carry一定要重新赋值为0,不然到下一位的时候carry的值就被污染了
	}

	ret.removeLendingZero();
	return ret;
}

BigInt BigInt:: operator*(const BigInt& bi) const {
	BigInt ret;
	ret.m_size = m_size + bi.m_size;
	for (int i = 0; i < ret.m_size; i++) {
		ret.m_data[i] = 0;
	}
	for (int i = 0; i < m_size; i++) {
		int carry = 0;
		for (int j = 0; j < bi.m_size; j++) {
			ret.m_data[i + j] += m_data[i] * bi.m_data[j] + carry;
			if (ret.m_data[i + j] >= Base) {
				carry = ret.m_data[i + j] / Base;
				ret.m_data[i + j] %= Base;
			}
			else carry = 0;
		}
		ret.m_data[i + bi.m_size] += carry;
	}
	ret.removeLendingZero();
	return ret;
}


int main() {
	int n;
	while (cin >> n) {
		BigInt ret(1);
		for (int i = 2; i <= n; i++) {
			ret = ret * i;
		}
		ret.print('\n');
	}
	return 0;
}

4.高精度除法

#include<iostream>
#include<cstring>
using namespace std;

const int Base = 1000;
const int Capacity = 10000;

class BigInt {
private:
	int m_data[Capacity];
	int m_size;

	void removeLeadingZeros();

public:
	BigInt();
	BigInt(int v);
	BigInt(const BigInt& bi);
	BigInt(char s[]);
	BigInt& operator=(const BigInt& bi);
	void print(char end);
	int compare(const BigInt& bi);

	BigInt operator+(const BigInt& bi) const;
	BigInt operator-(const BigInt& bi) const;
	BigInt operator*(const BigInt& bi) const;
	BigInt operator/(const BigInt& bi) const;
};

BigInt::BigInt(int v) {
	m_size = 0;
	while(v > 0) {
		m_data[m_size++] = v % Base;
		v /= Base;
	}
}

BigInt::BigInt() :m_size(0) {
	memset(m_data, 0, sizeof(m_data));
}

BigInt::BigInt(const BigInt& bi) :m_size(bi.m_size) {
	memcpy(m_data, bi.m_data, sizeof(bi.m_data));
}


BigInt::BigInt(char s[]) {
	m_size = 0;
	m_data[m_size] = 0;
	int b = 1;
	for (int i = strlen(s) - 1; i >= 0; i--) {
		m_data[m_size] += (s[i] - '0') * b;
		b *= 10;
		if (b >= Base) {
			m_size++;
			b = 1;
			m_data[m_size] = 0;
		}
	}
	if (m_data[m_size] > 0) {		//注意m_size可能会比原来多所以要判断
		m_size++;
	}
	removeLeadingZeros();
}

BigInt& BigInt::operator=(const BigInt& bi) {
	m_size = bi.m_size;
	memcpy(m_data, bi.m_data, sizeof(m_data));
	return *this;
}

void BigInt::print(char end) {
	cout << (m_size == 0 ? 0 : m_data[m_size - 1]);
	for (int i = m_size - 2; i >= 0; i--) {
		for (int j = Base / 10; j > 0; j/=10) {
			cout << (m_data[i] / j) % 10;
		}
	}
	cout << end;
}

int BigInt::compare(const BigInt& bi) {
	if (m_size != bi.m_size) {
		return m_size > bi.m_size ? 1 : -1;
	}
	for (int i = m_size - 1; i >= 0; i--) {
		if (m_data[i] != bi.m_data[i])return m_data[i] > bi.m_data[i] ? 1 : -1;
	}
	return 0;
}

void BigInt::removeLeadingZeros() {
	while (m_size > 0 && m_data[m_size - 1] == 0) {
		m_size--;
	}
}

BigInt BigInt::operator+(const BigInt& bi) const {
	BigInt ret;
	int i = 0, carry = 0;
	for (; i < m_size || i < bi.m_size || carry > 0; i++) {
		if (i < m_size) carry += m_data[i];
		if (i < bi.m_size) carry += bi.m_data[i];
		ret.m_data[i] = carry % Base;
		carry /= Base;
	}
	ret.m_size = i;

	return ret;
}

BigInt BigInt::operator-(const BigInt& bi) const {
	BigInt ret;
	int carry = 0;
	ret.m_size = m_size;		//被减数赋值给ret
	for (int i = 0; i < ret.m_size; i++) {
		ret.m_data[i] = m_data[i] - carry;
		if (i < bi.m_size) ret.m_data[i] -= bi.m_data[i];
		if (ret.m_data[i] < 0) {
			carry = 1;
			ret.m_data[i] += Base;
		}
		else {
			carry = 0;
		}
	}
	ret.removeLeadingZeros();
	return ret;
}

BigInt BigInt::operator*(const BigInt& bi) const {
	BigInt ret;
	ret.m_size = m_size + bi.m_size;
	for (int i = 0; i < ret.m_size; i++) {
		ret.m_data[i] = 0;
	}
	for (int i = 0; i < m_size; i++) {
		int carry = 0;
		for (int j = 0; j < bi.m_size; j++) {
			ret.m_data[i + j] += m_data[i] * bi.m_data[j] + carry;
			if (ret.m_data[i + j] >= Base) {
				carry = ret.m_data[i + j] / Base;
				ret.m_data[i + j] %= Base;
			}
			else {
				carry = 0;
			}
		}
		ret.m_data[i + bi.m_size] += carry;
	}
	ret.removeLeadingZeros();
	return ret;
}

BigInt BigInt::operator/(const BigInt& bi) const {
	BigInt ret, carry = 0;
	int l , r , mid;
	for (int i = m_size - 1; i >= 0; i--) {
		carry = carry * Base + m_data[i];
		l = -1;
		r = Base;
		while (l + 1 < r) {
			mid = (l + r) / 2;
			if ((bi * mid).compare(carry) <= 0) {
				l = mid;
			}
			else r = mid;
		}
		ret.m_data[i] = l;
		carry = carry - bi * l;
	}
	ret.m_size = m_size;
	ret.removeLeadingZeros();
	return ret;
}


int main() {
	char s1[10000], s2[10000];
	while (cin >> s1 >> s2) {
		BigInt a(s1), b(s2);
		if (a.compare(b) >= 0)(a - b).print('\n');
		else {
			cout << '-';
			(b - a).print('\n');
		}
	}
	

	return 0;
}

七、总结

高精度运算是一种重要的进阶数据结构技术,它能够处理超出常规数据类型表示范围的极大或极精确数值。通过自定义数据结构(如数组或字符串)和专门的算法实现(如加法、减法、乘法和除法),高精度运算能够在许多领域提供必要的精度和范围支持。掌握高精度运算技术对于提高程序的性能和效率具有重要意义。

结语

当前进阶的数据结构比之前学的初级数据结构要复杂了,希望大家一定要动手敲一遍代码,敲完之后提交到例题里检查一下是否正确,出现bug不用慌张,耐心差错,这样你的水平才能提升。

在这里插入图片描述

希望大家可以一键三连,后续我们一起学习,谢谢大家!!!

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/962576.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

MYSQL--一条SQL执行的流程,分析MYSQL的架构

文章目录 第一步建立连接第二部解析 SQL第三步执行 sql预处理优化阶段执行阶段索引下推 执行一条select 语句中间会发生什么&#xff1f; 这个是对 mysql 架构的深入理解。 select * from product where id 1;对于mysql的架构分层: mysql 架构分成了 Server 层和存储引擎层&a…

【4Day创客实践入门教程】Day2 探秘微控制器——单片机与MicroPython初步

Day2 探秘微控制器——单片机与MicroPython初步 目录 Day2 探秘微控制器——单片机与MicroPython初步MicroPython语言基础开始基础语法注释与输出变量模块与函数 单片机基础后记 Day0 创想启程——课程与项目预览Day1 工具箱构建——开发环境的构建Day2 探秘微控制器——单片机…

动态规划每日一练(四)

一、day1——最长数对链 题目链接&#xff1a; 646. 最长数对链 - 力扣&#xff08;LeetCode&#xff09;646. 最长数对链 - 给你一个由 n 个数对组成的数对数组 pairs &#xff0c;其中 pairs[i] [lefti, righti] 且 lefti < righti 。现在&#xff0c;我们定义一种 跟随…

事务02之锁机制

锁机制 文章目录 锁机制一&#xff1a;MySQL锁的由来与分类1&#xff1a;锁机制的分类 二&#xff1a;共享锁与排他锁1&#xff1a;共享锁(S锁)2&#xff1a;排他锁(X锁)3&#xff1a;锁的释放 二&#xff1a;表级别锁1&#xff1a;元数据锁(了解)2&#xff1a;意向锁3&#xf…

网络工程师 (8)存储管理

一、页式存储基本原理 &#xff08;一&#xff09;内存划分 页式存储首先将内存物理空间划分成大小相等的存储块&#xff0c;这些块通常被称为“页帧”或“物理页”。每个页帧的大小是固定的&#xff0c;例如常见的页帧大小有4KB、8KB等&#xff0c;这个大小由操作系统决定。同…

[EAI-026] DeepSeek-VL2 技术报告解读

Paper Card 论文标题&#xff1a;DeepSeek-VL2: Mixture-of-Experts Vision-Language Models for Advanced Multimodal Understanding 论文作者&#xff1a;Zhiyu Wu, Xiaokang Chen, Zizheng Pan, Xingchao Liu, Wen Liu, Damai Dai, Huazuo Gao, Yiyang Ma, Chengyue Wu, Bin…

(动态规划路径基础 最小路径和)leetcode 64

视频教程 1.初始化dp数组&#xff0c;初始化边界 2、从[1行到n-1行][1列到m-1列]依次赋值 #include<vector> #include<algorithm> #include <iostream>using namespace std; int main() {vector<vector<int>> grid { {1,3,1},{1,5,1},{4,2,1}…

cf1000(div.2)

Minimal Coprime最小公倍数 输入&#xff1a; 6 1 2 1 10 49 49 69 420 1 1 9982 44353 输出&#xff1a; 1 9 0 351 1 34371 代码

【单细胞第二节:单细胞示例数据分析-GSE218208】

GSE218208 1.创建Seurat对象 #untar(“GSE218208_RAW.tar”) rm(list ls()) a data.table::fread("GSM6736629_10x-PBMC-1_ds0.1974_CountMatrix.tsv.gz",data.table F) a[1:4,1:4] library(tidyverse) a$alias:gene str_split(a$alias:gene,":",si…

事务04之死锁,锁底层和隔离机制原理

死锁和事务底层原理 文章目录 死锁和事务底层原理一&#xff1a;MySQL中的死锁现象1&#xff1a;何为死锁1.1&#xff1a;死锁的概念1.2&#xff1a;死锁产生的四个必要条件&#xff1a; 2&#xff1a;MySQL的死锁2.1&#xff1a;死锁的触发2.2&#xff1a;MySQL的死锁如何解决…

Maven的单元测试

1. 单元测试的基本概念 单元测试&#xff08;Unit Testing&#xff09; 是一种软件测试方法&#xff0c;专注于测试程序中的最小可测试单元——通常是单个类或方法。通过单元测试&#xff0c;可以确保每个模块按预期工作&#xff0c;从而提高代码的质量和可靠性。 2.安装和配…

VirtualBox:跨磁盘导入已存的vdi磁盘文件顺便测试冷迁移

目录 1.背景 2.目的 3.步骤 3.1 安装在移动硬盘上 3.2.接管现有主机磁盘上的虚拟机 3.3接管迁移到移动硬盘的虚拟机 4. 结论 1.背景 电脑重新做了系统&#xff0c;然后找不到virtualbox的启动程序了&#xff0c;另外电脑磁盘由于存储了其他文件已经爆红&#xff0c;无法…

二级C语言:二维数组每行最大值与首元素交换、删除结构体的重复项、取出单词首字母

目录 一、程序填空 --- 二维数组每行最大值与首元素交换 题目 分析 知识点 --- 交换语句 二、程序修改 --- 删除结构体的重复项 题目 分析 三、程序设计 --- 取出单词首字母 题目 分析 前言 本章讲解&#xff1a;二维数组每行最大值与首元素交换、删除结构体的重复项…

优盘恢复原始容量工具

买到一个优盘&#xff0c;显示32mb&#xff0c;我见过扩容盘&#xff0c;但是这次见到的是缩容盘&#xff0c;把2g的容量缩成32MB了&#xff0c;首次见到。。用芯片查询工具显示如下 ChipsBank(芯邦) CBM2199E 使用以下工具&#xff0c;恢复原始容量。。 其他CMB工具可能不行…

面对企业文件交换难题,镭速跨网文件交换系统是如何解决的?

在当今这个数字化快速发展的时代&#xff0c;企业越来越依赖于数据交换来维持其业务运作。无论是内部网络之间的沟通还是与外部合作伙伴的数据共享&#xff0c;高效且安全的跨网文件交换都显得尤为重要。然而&#xff0c;在实际操作中&#xff0c;许多企业面临着各种各样的挑战…

黑马点评 - 商铺类型缓存练习题(Redis List实现)

首先明确返回值是一个 List<ShopType> 类型那么我们修改此函数并在 TypeService 中声明 queryTypeList 方法&#xff0c;并在其实现类中实现此方法 GetMapping("list")public Result queryTypeList() {return typeService.queryTypeList();}实现此方法首先需要…

计算机毕业设计Python+CNN卷积神经网络高考推荐系统 高考分数线预测 高考爬虫 协同过滤推荐算法 Vue.js Django Hadoop 大数据毕设

温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 温馨提示&#xff1a;文末有 CSDN 平台官方提供的学长联系方式的名片&#xff01; 作者简介&#xff1a;Java领…

知识库管理如何推动企业数字化转型与创新发展的深层次探索

内容概要 在当今数字化转型的大背景下&#xff0c;知识库管理日益显现出其作为企业创新发展的核心驱动力的潜力。这种管理方式不仅仅是对信息的存储与检索&#xff0c;更是一种赋能&#xff0c;以提升决策效率和员工创造力。企业能够通过系统地整合和管理各类知识资源&#xf…

【Leetcode】463. 岛屿的周长

一、题目描述 给定一个KaTeX parse error: Undefined control sequence: \x at position 4: row\̲x̲\col的二维网格地图 g r i d grid grid&#xff0c;其中&#xff1a; g r i d [ i ] [ j ] 1 grid[i][j]1 grid[i][j]1表示陆地&#xff0c; g r i d [ i ] [ j ] 0 grid[…

企业微信远程一直显示正在加载

企业微信远程一直显示正在加载 1.问题描述2.问题解决 系统&#xff1a;Win10 1.问题描述 某天使用企业微信给同事进行远程协助的时候&#xff0c;发现一直卡在正在加载的页面&#xff0c;如下图所示 2.问题解决 经过一番查找资料后&#xff0c;我发现可能是2个地方出了问题…