首页 > 其他分享 >My头文件(7)

My头文件(7)

时间:2023-09-30 14:23:20浏览次数:32  
标签:vd i4 tail Vec 头文件 array My define

自定义头文件"almighty.hpp"

持续更新

almighty.h内部内容:

#ifndef _ALMIGHTY_
#define _ALMIGHTY_

#include<bits/stdc++.h>

#define dsm Data_Structure_Moonspace

using namespace std;

#define sd signed
#define ud unsigned
#define ct const
#define sc static
typedef int i4;
typedef long long i8;
typedef float f4;
typedef double f8;
typedef long double f16;
typedef void vd;
typedef bool bl;
typedef char cr;
typedef string STR;

#define ope operator

#define TE true
#define FE false

#define CI cin
#define CO cout
#define EL endl
#define Sf scanf
#define Pf printf
#define Gc getchar
#define Pc putchar
#define QIO_C98 ios::sync_with_stdio(FE), CI.tie(FE), CO.tie(FE);
#define QIO_C11 ios::sync_with_stdio(FE), CI.tie(nullptr), CO.tie(nullptr);

#define Fr for
#define Up(a, b, c, d) Fr (i8 a = b; a <= c; a += d)
#define Dn(a, b, c, d) Fr (i8 a = b; a >= c; a -= d)

#define pi 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921642019
#define e 2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642742746639193200305992181741359662904357290033429526059563073813232862794349076323382988075319525101901157383418793070215408914993488416750924476146066808226480016847741185374234544243710753907774499206955170276183860626133138458300075204493382656029760673711320070932870912744374704723069697720931014169283681902551510865746377211125238978442505695369677078544996996794686445490598793163688923009879312773617821542499922957635148220826989519366803318252886939849646510582093923982948879332036250944311730123819706841614039701983767932068328237646480429531180232878250981945581530175671736133206981125099618188159304169035159888851934580727386673858942287922849989208680582574927961048419844436346324496848756023362482704197862320900216099023530436994184914631409343173814364054625315209618369088870701676839642437814059271456354906130310720851038375051011574770417189861068739696552126715468895703503
#define Cpi 3.14159265358979
#define Ce 2.71828182845904

vd read(i4&);
i4 Abs(i4);
i4 lowbit(i4);
i4 countbit(i4);
i4 qpow(i4, i4, ct i4);
i4 inv(i4, i4);
i4 gcd(i4, i4);
i4 qgcd(i4, i4);
i4 exgcd(i4, i4, i4&, i4&);
vd Swap(i4&, i4&);

template<class T> vd cin_arr(T[], i4, i4);
template<class T> vd cout_arr(T[], i4, i4, cr);

namespace dsm {
	template<class Vec_name>
	class Vec {
		public:
			i4 head, tail;
			vector<Vec_name> Vec_array;
			Vec_name ope[](i4);
			vd fill_Vec(Vec_name);
			vd fill_Vec(i4, i4, Vec_name);
			Vec(i4, Vec_name);
			Vec(i4, i4, Vec_name);
			i4 PUSH_front(Vec_name);
			i4 POP_front();
			i4 PUSH_back(Vec_name);
			i4 POP_back();
			i4 Size();
			vd sort_Vec(bl, bl);
			vd sort_Vec(i4, i4, bl, bl);
			vd cin_Vec();
			vd cin_Vec(i4, i4);
			vd cout_Vec(cr);
			vd cout_Vec(i4, i4, cr);
	};
}

#endif

almighty.hpp实现:

#include"almighty.h"

vd read(i4 &num) {
	i4 sgn = 0;
	cr ch = Gc();
	while (~ch && !isdigit(ch)) sgn |= ch == '-', ch = Gc();
	while (~ch && isdigit(ch)) num = (num << 1) + (num << 3) + (ch ^ 48), ch = Gc();
	if (sgn) num = -num;
}
i4 Abs(i4 x) {
	i4 a = x >> 31;
	return (x ^ a) - a;
}
i4 lowbit(i4 x) {
	return x & (-x);
}
i4 countbit(i4 x) {
	i4 count = 0;
	while (x) {
		x = x & x - 1;
		count ++;
	}
	return count;
}
i4 qpow(i4 a, i4 b, ct i4 p) {
	i4 res = 1;
	for (; b; b >>= 1ll, a = (i8)a * a % p)
		if (b & 1)
			res = (i8)res * a % p;
	return res;
}
i4 inv(i4 n, i4 p) {
	return qpow(n, p - 2, p);
}
i4 gcd(i4 a, i4 b) {
	return !b ? a : gcd(b, a % b);
}
i4 qgcd(i4 a, i4 b) {
	i4 x = __builtin_ctz(a), y = __builtin_ctz(b), z = min(x, y), k;
	b >>= y;
	while (a) {
		a >>= x;
		k = b - a;
		x = __builtin_ctz(k);
		if (a < b) b = a;
		a = k < 0 ? -k : k;
	}
	return b << z;
}
i4 exgcd(i4 a, i4 b, i4 &x, i4 &y) {
	if (!b) {
		x = 1, y = 0;
		return a;
	}
	i4 d = exgcd(b, a % b, x, y), t = x;
	x = y, y = t - (a / b) * y;
	return d;
}
vd Swap(i4 &a, i4 &b) {
	a ^= b, b ^= a, a ^= b;
}

template<class T> vd cin_arr(T arr[], i4 first, i4 size) {
	Up(i, 0, size - 1, 1) CI >> arr[i];
}
template<class T> vd cout_arr(T arr[], i4 first, i4 size, cr _and_) {
	Up(i, 0, size - 1, 1) CO << arr[i] << _and_;
}

template<class Vec_name> Vec_name dsm::Vec<Vec_name>::ope[](i4 index) {
	return Vec_array.at(index);
}
template<class Vec_name> vd dsm::Vec<Vec_name>::fill_Vec(Vec_name content) {
	//if (Vec_array.size() <= tail - head) Vec_array.resize(tail + 5);
	Up(i, head, tail, 1) Vec_array.at(i) = content;
}
template<class Vec_name> vd dsm::Vec<Vec_name>::fill_Vec(i4 l, i4 r, Vec_name content) {
	//if (Vec_array.size() <= tail - head) Vec_array.resize(tail + 5);
	l = max(0, l), r = min(tail + 2, r);
	Up(i, l, r, 1) Vec_array.at(i) = content;
}
template<class Vec_name> dsm::Vec<Vec_name>::Vec(i4 r, Vec_name content) {
	head = 0, tail = max(1, r);
	Vec_array.resize(tail + 10);
	fill_Vec(0, tail, 0);
	fill_Vec(content);
}
template<class Vec_name> dsm::Vec<Vec_name>::Vec(i4 l, i4 r, Vec_name content) {
	head = max(min(l, r), 0), tail = max(max(l, r), 1);
	Vec_array.resize(tail + 10);
	fill_Vec(0, tail, 0);
	fill_Vec(content);
}
template<class Vec_name> i4 dsm::Vec<Vec_name>::PUSH_front(Vec_name push) {
	if (!head) return -1;
	Vec_array[-- head] = push;
	return 1;
}
template<class Vec_name> i4 dsm::Vec<Vec_name>::POP_front() {
	if (head >= tail) return -1;
	++ head;
	return 1;
}
template<class Vec_name> i4 dsm::Vec<Vec_name>::PUSH_back(Vec_name push) {
	if (tail >= Vec_array.size()) Vec_array.resize(tail + 10, 0);
	Vec_array[++ tail] = push;
	return 1;
}
template<class Vec_name> i4 dsm::Vec<Vec_name>::POP_back() {
	if (tail <= head) return -1;
	-- tail;
	return 1;
}
template<class Vec_name> i4 dsm::Vec<Vec_name>::Size() {
	if (head > tail) return -1;
	return tail - head + 1;
}
template<class Vec_name> vd dsm::Vec<Vec_name>::sort_Vec(bl way, bl order) {
	if (way)
		if (order) sort(Vec_array.begin() + head, Vec_array.begin() + tail);
		else sort(Vec_array.begin() + head, Vec_array.begin() + tail, greater<Vec_name>());
	else
		if (order) table_sort(Vec_array.begin() + head, Vec_array.begin() + tail);
		else table_sort(Vec_array.begin() + head, Vec_array.begin() + tail, greater<Vec_name>());
}
template<class Vec_name> vd dsm::Vec<Vec_name>::sort_Vec(i4 l, i4 r, bl way, bl order) {
	if (way)
		if (order) sort(Vec_array.begin() + l, Vec_array.begin() + r);
		else sort(Vec_array.begin() + l, Vec_array.begin() + r, greater<Vec_name>());
	else
		if (order) table_sort(Vec_array.begin() + l, Vec_array.begin() + r);
		else table_sort(Vec_array.begin() + l, Vec_array.begin() + r, greater<Vec_name>());
}
template<class Vec_name> vd dsm::Vec<Vec_name>::cin_Vec() {
	Up(i, head, tail, 1) CI >> Vec_array.at(i);
}
template<class Vec_name> vd dsm::Vec<Vec_name>::cin_Vec(i4 l, i4 r) {
	l = max(0, min(l, r)), r = max(0, max(l, r));
	Up(i, l, r, 1) CI >> Vec_array.at(i);
}
template<class Vec_name> vd dsm::Vec<Vec_name>::cout_Vec(cr _and_) {
	Up(i, head, tail, 1) CO << Vec_array.at(i) << _and_;
}
template<class Vec_name> vd dsm::Vec<Vec_name>::cout_Vec(i4 l, i4 r, cr _and_) {
	l = max(0, min(l, r)), r = max(0, max(l, r));
	Up(i, l, r, 1) CO << Vec_array.at(i) << _and_;
}

 

标签:vd,i4,tail,Vec,头文件,array,My,define
From: https://www.cnblogs.com/vectorSpace-blog/p/17737795.html

相关文章

  • mysql基础语句
    1.基本语句mysql-uroot-p--连接数据库showdatabases--列出所有数据库createdatabasexxx--创建一个数据库usexxx--切换到xxx数据库showtables--列出当前数据库所有的表--注释/*(多行注释)hellor3ality*/数据库xxx语言DDLdefineDMLmanage......
  • Nacos连接Mysql8连接失败问题
    一、问题复现Nacos、Mysql容器均开机自启。Nacos配置了Mysql,配置确认没有问题,发现每次重启服务器,Nacos都无法直接成功连接mysql。每次启动完Nacos后,需要用Datagrip连接一次Mysql,再dockerrestartnacos才可以连上Mysql。Nacos启动报错NoDataSourceset,详情如下......
  • mysql
    1.基本语句mysql-uroot-p--连接数据库showdatabases--列出所有数据库createdatabasexxx--创建一个数据库usexxx--切换到xxx数据库showtables--列出当前数据库所有的表--注释/*(多行注释)hellor3ality*/数据库xxx语言DDLdefineDMLmanage......
  • MySQL常用指令
    注意所有的命令都要用分号结尾!!!!1、查看MySQL中有那些数据库:showdatabases(默认自带了四个数据库)2、如何使用某个数据库:use数据库名称3、如何创建数据库:createdatabase数据库名称4、导入SQL指令:sourceSQL指令(SQL指令可以是文件的路径,但是文件的路径一定不要有中文!!)5、不看表......
  • Mybatis - 找不到字段 'default_connector'
    通过Lombok自动生成的getter/setter可能与mybatisplus自动映射实体类的getter/setter存在差异,这个问题在Spring反序列Body数据也存在,详细查看视频:我为什么不喜欢lombok,这个问题大家怎么看,高级分析技巧。而我遇到的问题是有一个default开头的属性,这似乎也是Java......
  • java springboot项目,mybatisplus,import com.baomidou.mybatisplus.core.mapper.BaseMa
    <dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.1.2</version><!--用版本2.1.9就不行,UserMapper里BaseMapper爆红--></dependency>我的结果是,......
  • Java面试题之MyBatis
    1.MyBatis中#{}和${}的区别是什么#{}是预编译处理,${}是字符串替换;Mybatis在处理#{}时,会将sql中的#{}替换为?号,调用PreparedStatement的set方法来赋值;Mybatis在处理${}时,就是把${}替换成变量的值;使用#{}可以有效的防止SQL注入,提高系统安全性。2.M......
  • QT: 电子商城系统-MYSQL数据库代码
    QT: 第17章【统合实例】电子商城系统MYSQL代码:/*SQLyogUltimatev12.3.2(64bit)MySQL-8.0.11:Database-emarket**********************************************************************//*!40101SETNAMESutf8*/;/*!40101SETSQL_MODE=''*/;/*!40......
  • CF1425F Flamingoes of Mystery 题解
    题目传送门前置知识前缀和&差分解法令\(sum_k=\sum\limits_{i=1}^{k}a_k\)。考虑分别输入\(sum_2\simsum_n\),故可以由于差分知识得到\(a_i=sum_i-sum_{i-1}(3\lei\len)\),接着输入\(a_2+a_3\)的值从而求出\(a_2=sum_3-a_3,a_1=sum_2-a_2\)。同时因为是交互题,记......
  • Mysql 日期计算相差年、月、周、日数整理
    1、相差年数SELECTNOW()当前日期,DATE_ADD(NOW(),INTERVAL-400DAY)历史日期,TIMESTAMPDIFF(YEAR,DATE_ADD(NOW(),INTERVAL-400DAY),NOW())AS相差年;2、相差月数 SELECTNOW()当前日期,DATE_ADD(NOW(),INTERVAL-400DAY)历史日期,TIMESTAMPDIFF(MONTH,......