上次的发现bug,现在的是新版本
加入计算几何内容,目前无空行不像某人
目前283行。
#include<bits/stdc++.h>
using namespace std;
#define R read()
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define int long long
#define inf 0x3f3f3f3f
#define mod1 1000000007
#define mod2 998244353
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i>=b;i--)
#define m1(a,b) memset(a,b,sizeof a)
#define m2(a,b) memcpy(a,b,sizeof b)
using ld = long double;
using str = string;
using pi = pair<int,int>;
using pd = pair<ld,ld>;
using vi = vector<int>;
using vb = vector<bool>;
using vd = vector<ld>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpd = vector<pd>;
const ld PI = acos((ld)-1);
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
template<class T> using pqg = priority_queue<T,vector<T>,greater<T>>;
template<typename T, typename U> void umin(T& a, U b){if (a > b) a = b;}
template<typename T, typename U> void umax(T& a, U b){if (a < b) a = b;}
namespace IO{
inline int read()
{
int X=0; bool flag=1; char ch=getchar();
while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
if(flag) return X;
return ~(X-1);
}
inline void write(int X)
{
if(X<0) {X=~(X-1); putchar('-');}
if(X>9) write(X/10);
putchar(X%10+'0');
}
}
namespace math{
int lowbit(int x)
{
return x & -x;
}
int qmi(int a,int k,int p)
{
int res=1%p;
while(k)
{
if(k&1) res=res*a%p;
a=a*a%p;
k>>=1;
}
return res;
}
bool is_prime(int x)
{
if (x < 2) return false;
for (int i = 2; i <= x / i; i ++ )
if (x % i == 0)
return false;
return true;
}
int gcd(int a,int b)
{
return b?gcd(b,a%b):a;
}
int exgcd(int a,int b,int &x,int &y)
{
if(!b)
{
x=1;y=0;
return a;
}
int d=exgcd(b,a%b,y,x);
y-=(a/b)*x;
return d;
}
vector<int> add(vector<int> &A, vector<int> &B) // C = A + B, A >= 0, B >= 0
{
if (A.size() < B.size()) return add(B, A);
vector<int> C;
int t = 0;
for (int i = 0; i < A.size(); i ++ )
{
t += A[i];
if (i < B.size()) t += B[i];
C.push_back(t % 10);
t /= 10;
}
if (t) C.push_back(t);
return C;
}
vector<int> sub(vector<int> &A, vector<int> &B) // C = A - B, 满足A >= B, A >= 0, B >= 0
{
vector<int> C;
for (int i = 0, t = 0; i < A.size(); i ++ )
{
t = A[i] - t;
if (i < B.size()) t -= B[i];
C.push_back((t + 10) % 10);
if (t < 0) t = 1;
else t = 0;
}
while (C.size() > 1 && C.back() == 0) C.pop_back();
return C;
}
vector<int> mul(vector<int> &A,vector<int> &B) // C = A * B, A >= 0, b >= 0
{
vector<int> C;
int t = 0, v = 1;
for (int i = 0; i < A.size() || t; i ++ )
{
v = i + 1;
if (i < A.size()) {
vector<int> ans;
int b = A[i], t1 = 0;
for (int j = 0; j < B.size() || t1; j ++ , v ++ )
{
if (j < B.size()) t1 += b * B[j];
if (v >= C.size()) C.push_back(t1 % 10);
else {
C[v] += t1;
C[v] %= 10;
}
t1 /= 10;
}
}
}
while (C.size() > 1 && C.back() == 0) C.pop_back();
return C;
}
vector<int> mul(vector<int> &A, int b) // C = A * b, A >= 0, b >= 0
{
vector<int> C;
int t = 0;
for (int i = 0; i < A.size() || t; i ++ )
{
if (i < A.size()) t += A[i] * b;
C.push_back(t % 10);
t /= 10;
}
while (C.size() > 1 && C.back() == 0) C.pop_back();
return C;
}
vector<int> div(vector<int> &A, int b, int &r) // A / b = C ... r, A >= 0, b > 0
{
vector<int> C;
r = 0;
for (int i = A.size() - 1; i >= 0; i -- )
{
r = r * 10 + A[i];
C.push_back(r / b);
r %= b;
}
reverse(C.begin(), C.end());
while (C.size() > 1 && C.back() == 0) C.pop_back();
return C;
}
int phi(int x)
{
int res = x;
for (int i = 2; i <= x / i; i ++ )
if (x % i == 0)
{
res = res / i * (i - 1);
while (x % i == 0) x /= i;
}
if (x > 1) res = res / x * (x - 1);
return res;
}
}
namespace tu{
int h[100010],w[100010],e[100010],ne[100010],idx;
void add(int a,int b)
{
e[idx]=b,ne[idx]=h[a],h[a]=idx++;
}
void add(int a,int b,int c)
{
e[idx]=b,w[idx]=c,ne[idx]=h[a],h[a]=idx++;
}
}
int ff(int x)
{
return (int)(pow(10,x))+10;
}
namespace geometric{
const double eps = 1e-8;
int sign(double x) // 符号函数
{
if (fabs(x) < eps) return 0; // x为0,则返回0
if (x < 0) return -1; // x为负数,则返回-1
return 1; // x为正数,则返回1
}
int dcmp(double x, double y) // 比较两数大小
{
if (fabs(x - y) < eps) return 0; // x == y, 返回0
if (x < y) return -1; // x < y, 返回-1
return 1; // x > y, 返回1
}
pd operator+ (pd a, pd b) // 向量加法
{
return {a.f + b.f, a.s + b.s};
}
pd operator- (pd a, pd b) // 向量减法
{
return {a.f - b.f, a.s - b.s};
}
pd operator* (pd a, double t) // 向量数乘
{
return {a.f * t, a.s * t};
}
pd operator/ (pd a, double t) // 向量除以常数
{
return {a.f / t, a.s / t};
}
double operator* (pd a, pd b) // 外积、叉积
{
return a.f * b.s - a.s * b.f;
}
double operator& (pd a, pd b) // 内积、点积
{
return a.f * b.f + a.s * b.s;
}
double area(pd a, pd b, pd c) // 以a, b, c为顶点的有向三角形面积
{
return (b - a) * (c - a);
}
double get_len(pd a) // 求向量长度
{
return sqrt(a & a);
}
double get_dist(pd a, pd b) // 求两个点之间的距离
{
return get_len(b - a);
}
double project(pd a, pd b, pd c) // 求向量ac在向量ab上的投影
{
return ((c - a) & (b - a)) / get_len(b - a);
}
pd rotate(pd a, double b) // 向量a逆时针旋转角度b
{
return {a.f * cos(b) + a.s * sin(b), -a.f * sin(b) + a.s * cos(b)};
}
pd norm(pd a) // 矩阵标准化(将长度变成1)
{
return a / get_len(a);
}
bool on_segment(pd p, pd a, pd b) // 点p是否在线段ab上(包含端点a、b)
{
return !sign((p - a) * (p - b)) && sign((p - a) & (p - b)) <= 0;
}
pd get_line_intersection(pd p, pd v, pd q, pd w) // 求两直线交点:p + vt, q + wt
{
auto u = p - q;
auto t = w * u / (v * w);
return p + v * t;
}
}
using namespace IO;
using namespace math;
using namespace tu;
signed main(){
return 0;
}
这该不会就是一个把n个模板丢一块吧....bu
我们有个同学说经常报错,我无语了
不能使用h,e,ne,idx,w,add,phi,add,sub,mul,div,exgcd,gcd,is_prime.lowbit,qmi,read,write,math,IO作为函数名或变量名
原来如此
考试的时候有啥用?
这是干啥的啊
…