自定义头文件"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;
#define Sf scanf
#define Pf printf
#define Gc getchar
#define Up(a, b, c, d) for (a = b; a <= c; a += d)
#define Dn(a, b, c, d) for (a = b; a >= c; a -= d)
i4 lowbit(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);
#endif
函数实现:
#include"almighty.h"
i4 lowbit(i4 x) {
return x & (-x);
}
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;
}
希望会有点用。。。
标签:typedef,return,res,i4,头文件,My,define From: https://www.cnblogs.com/vectorSpace-blog/p/17690880.html