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

My头文件(3)

时间:2023-09-15 16:57:25浏览次数:24  
标签:typedef ch return res i4 头文件 My define

自定义头文件"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 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 (a = b; a <= c; a += d)
#define Dn(a, b, c, d) Fr (a = b; a >= c; a -= d)

i4 read();
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&);

#endif

函数实现:

#include"almighty.h"

i4 read() {
	i4 res = 0, sgn = 0;
	cr ch = Gc();
	while (~ch && !isdigit(ch)) sgn |= ch == '-', ch = Gc();
	while (~ch && isdigit(ch)) res = (res << 1) + (res << 3) + (ch ^ 48), ch = Gc();
	return sgn ? -res : res;
}
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;
}

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

相关文章

  • CentOS 7.6安装MySQL8
    下载yum源yuminstall-ywgetwgethttps://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm安装yum源rpm-ivhmysql80-community-release-el7-5.noarch.rpm安装MySQLyuminstall-ymysql-server启动mysql服务systemctlstartmysqld查看......
  • MySQL实战实战系列 00 开篇词 这一次,让我们一起来搞懂MySQL
    你好,我是林晓斌,网名“丁奇”,欢迎加入我的专栏,和我一起开始MySQL学习之旅。我曾先后在百度和阿里任职,从事MySQL数据库方面的工作,一步步地从一个数据库小白成为MySQL内核开发人员。回想起来,从我第一次带着疑问翻MySQL的源码查到答案至今,已经有十个年头了。在这个过程中,......
  • MySQL篇:第四章_详解DML语言
    DML语言插入一、方式一语法:insertinto表名(字段名,...)values(值1,...);特点:1、字段类型和值类型一致或兼容,而且一一对应2、可以为空的字段,可以不用插入值,或用null填充3、不可以为空的字段,必须插入值4、字段个数和值的个数必须一致5、字段可以省略,但默认所有字段,并且......
  • Navicat连接Mysql数据显示2059 - authentication plugin ‘caching_sha2_password‘的
    安装Mysql8.0,使用navicat登录时显示如下错误提示 错误原因:MySQL新版本(8以上版本)的用户登录账户加密方式是【caching_sha2_password】,Navicat不支持这种用户登录账户加密方式。解决办法:1.打开MySQL命令行客户端 2.输入登录密码登录,查看加密方式,命令:showvariableslike'd......
  • .net链接mysql报错:给定关键字不在字典中,解决方案
    如果看到这个报错信息,大概率是的原因是:1、连接字符串中编码和数据库实际编码不一致。解决方案:修改连接字符串中的编码即可,保证和mysql中编码一致。 2、MySql.Data.dll版本不一致。解决方案:去mysql官网下载对应版本的dll;或使用VS的Nuget更新MySql.Data.dll。......
  • MySQL存储过程、索引、分表对比
    MySQL存储过程、索引和分表是用于提高查询效率的三种不同方法,它们各自对查询效率有不同的影响和应用场景。以下是它们的对比:MySQL存储过程:影响查询效率:存储过程通常不直接影响查询效率,因为它们是用于封装查询逻辑和执行多个SQL语句的数据库对象。存储过程主要有助于减少网络......
  • MybatisPlus之prim标签
    MybatisPlus之trim标签<trimprefix=""suffix=""suffixOverrides=""prefixOverrides=""></trim>prefix:在trim标签内sql语句加上前缀。suffix:在trim标签内sql语句加上后缀。prefixOverrides:指定去除多余的前缀内容suffixOverrides:指定去除多余的后缀内容,如:s......
  • mysql8.0版本的下载与安装
    1.首先下载mysql,官网下载https://www.mysql.com/ 2.到页面底端,选择社区版 3.选择windows版本 4.选择较大的那个下载链接 5.跳过注册,直接下载二、Mysql8.0的安装1.双击下载后的安装文件,点击no,即自动升级选项  2.选择下一步  3. ......
  • MySQL 切换数据库、用户卡死:“You can turn off this feature to get a quicker start
    数据量很大的话,常规切换数据库会把里面所有的表遍历一遍,会很慢甚至是卡死。解决方法:登录的时候直接在最后面加一个-A就行了。[root@localhost~]#"/usr/local/mysql-8.0.11/bin/mysql"-uroot-p123456-A 实战演示:我演示的数据库就是一个数据量很大的数据库,切换数据库......
  • 针对部分设置完密码出现MY_PC账户的解决办法
    看了图示很简单吧,就按照这个操作按照提示搞定即可,搞完后会提示重启,重启后就可以了。......