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

My头文件(5)

时间:2023-09-29 14:55:53浏览次数:34  
标签:typedef vd i4 return Vec 头文件 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 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;
			vd fill_Vec(Vec_name);
			Vec(i4, Vec_name);
			Vec(i4, i4, Vec_name);
			vd cin_Vec();
			vd cout_Vec(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> 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> dsm::Vec<Vec_name>::Vec(i4 r, Vec_name content) {
	head = 0, tail = max(1, r), 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), fill_Vec(content);
}
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>::cout_Vec(cr _and_) {
	Up(i, head, tail, 1) CO << Vec_array.at(i) << _and_;
}

 

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

相关文章

  • java——mysql随笔
         索引简介:                                                                 1 ......
  • 读高性能MySQL(第4版)笔记17_复制(下)
    1. 复制切换1.1. 复制是高可用性的基础1.1.1. 总是保留一份持续更新的副本数据,会让灾难恢复更简单1.2. “切换副本”(promotingareplica)和“故障切换”(failingover)是同义词1.2.1. 意味着源服务器不再接收写入,并将副本提升为新的源服务器1.3. 计划内切换1.3.1. 常......
  • My头文件(4)
    自定义头文件"almighty.hpp"持续更新almighty.h内部内容:#ifndef_ALMIGHTY_#define_ALMIGHTY_#include<bits/stdc++.h>usingnamespacestd;#definesdsigned#defineudunsigned#definectconst#definescstatictypedefinti4;typedeflonglongi8;t......
  • mysql将换行替换成空格
    #char(10)换行符char(13)回车符号select*fromview_nichtware_wms_inventorywhereDESCRIPTIONlikeconcat('%',char(10),'%')andSKU='DMKT-20220124-013';#去除换行和回车符号REPLACE(REPLACE(remarks,char(13),''),char(10),'......
  • MySQL 45讲笔记(2)
    全局锁和表锁根据加锁的范围,MySQL里面的锁大致可以分成全局锁、表级锁和行锁三类全局锁顾名思义,全局锁就是对整个数据库实例加锁。MySQL提供了一个加全局读锁的方法,命令是Flushtableswithreadlock(FTWRL)。当你需要让整个库处于只读状态的时候,可以使用这个命令,之后其他线......
  • MySql 数据库 对表中数据的操作
    对表中数据的操作--向表中插入数据insert[ignore]into表名(字段列表)values(值列表)usescoredb;showtables;descdepartments;insertintodepartments(id,deptno,deptname,director,location)values(1,101,"张xx","张院长","新乡"......
  • MySql 数据 管理表的操作
    管理表的操作usescoredb;--查看数据库中有哪些表showtables;showtablesfrombipowernode;--查看数据表的基础结构showcolumnsfromdepartment;descdepartment;--查看表的详细结构,查看表的建表语句showcreatetabledepartment;--1.修改表名altertab......
  • MYSQL时间差函数
    一、TIMESTAMPDIFF语法TIMESTAMPDIFF(unit,datetime1,datetime2)返回datetime2-datetime1的时间差,结果单位由unit参数决定unit合法参数second秒minute分hour小时day天week周month月quarter季度year年示例SELECTTIMESTAMPDIFF(......
  • Mybatis-Flex核心功能之@Table
    1、能干啥?@Table主要是用于给Entity实体类添加标识,用于描述实体类和数据库表的关系,以及对实体类进行的一些功能辅助。例如:数据库有一张tb_member的会员表这时候我们就可以使用@Table去绑定对应的实体和表的对应关系2、怎么玩?先看看@Table注解内部结构public@in......
  • 数据库中什么是内连接、外连接、交叉连接、笛卡尔积;MySQL 的内连接、左连接、右连接有
    一、什么是内连接、外连接、交叉连接、笛卡尔积呢内连接(innerjoin):取得两张表中满足存在连接匹配关系的记录;外连接(outerjoin):不只取得两张表中满足存在连接匹配关系的记录,还包括某张表(或者两张表)中不满足匹配关系的记录。交叉连接(crossjoin):显示两张表所有记录一一对应,没有匹配关系......