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

My头文件(4)

时间:2023-09-28 23:34:43浏览次数:36  
标签:typedef vd arr i4 return 头文件 My define

自定义头文件"almighty.hpp"

持续更新

almighty.h内部内容:

#ifndef _ALMIGHTY_
#define _ALMIGHTY_

#include<bits/stdc++.h>
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 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)

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);

#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) cin >> arr[i];
}
template<class T>
vd cout_arr(T arr[], i4 first, i4 size, cr _and_) {
	Up(i, 0, size - 1, 1) cout << arr[i], Pc(cr);
}

 

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

相关文章

  • 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):显示两张表所有记录一一对应,没有匹配关系......
  • MySQL安装--yum(CentOS7 + MySQL 5.7.35)
    Linux系统-部署-运维系列导航 MySQL常用安装方式有3种:rpm安装、yum安装、二进制文件安装。本文介绍yum安装方式。 组件安装操作步骤参考 组件安装部署手册模板,根据不同组件的安装目标,部分操作可以省略。本文将按照该参考步骤执行。 一、获取组件可执行程序库,包括主程......
  • mysql数据库安装
    目录1、MySQL安装包下载2、创建安装目录3、解压安装包4、为系统添加mysql组和mysql用户5、mysql目录权限拥有者修改6、安装准备7、安装MySQL7.1安装依赖方式8、安装完成,启动服务9、配置MySQL登录密码,并授权主机登陆。(1)   获取MySQL安装时生成的随机密码(2)   通......
  • k8s部署nginx+php+mysql
    mysql部署参考我之前文档一.hostPath创建项目1.编辑dockerfilevidockerfileiFROMdocker.io/openshift/base-centos7:latest#MAINTAINERfeiyu"[email protected]"RUNyummakecacheRUNyum-yinstallphp-fpmphpphp-gdphp-mysqlphp-mbstringphp-xmlphp-mcryptphp-im......