√const double pi=acos(-1); 等于π(骚操作)
√防止进位:double flag=t-0.005;
√快读:void read(int &x){
char ch = getchar();x = 0;
for (; ch < '0' || ch > '9'; ch = getchar());
for (; ch >='0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
}
√最大公约数(递归法):ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
√快速幂 ll powmod(ll a,ll b) {ll res=1;a%=mod;
assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
gcd和快速幂:
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod;
assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
经典头文件定义:
一些经典的头部定义:
#include <bits/stdc++.h>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
#include<stdlib.h>
#include<queue>
#include<vector>
#include<assert.h>
#include<map>
#include<set>
#include<stack>
#define mem(a,x) memset(a,x,sizeof(a))
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);
for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ios::sync_with_stdio(false);
结构体定义排序的方法:
struct node
{
int u,w;
node(int a,int b){u=a,w=b;}
bool operator<(const node&t)const
{
return w>t.w;
}
};
struct edge {
int u, v, w;
}e[N];
bool operator < (edge a, edge b) {
return a.w < b.w;
}
typedef struct node
{
int p,w;
node (int a,int b){p=a;w=b;}
friend bool operator <(node a,node b)
{
if(a.w!=b.w) return a.w<b.w;
return a.p>b.p;
}
};