库
shikongyeyv · · 算法·理论
#include<bits/stdc++.h>
using namespace std;
namespace skyy{
typedef long long ll;
typedef unsigned long long ull;
inline ull readull(){
char c=getchar();
ull r=0;
while(c<48||c>57)c=getchar();
while(c>47&&c<58)r=(r<<1)+(r<<3)+c-48,c=getchar();
return r;
}inline unsigned readuint(){
char c=getchar();
unsigned int r=0;
while(c<48||c>57)c=getchar();
while(c>47&&c<58)r=(r<<1)+(r<<3)+c-48,c=getchar();
return r;
}inline void printull(ull x){
if(x>9)printull(x/10);
putchar(x%10+48);
}inline void printuint(unsigned int x){
if(x>9)printuint(x/10);
putchar(x%10+48);
}inline ll readll(){
char c=getchar();
ll r=0;
bool s=0;
while((c<48||c>57)&&c!=45)c=getchar();
if(c==45)s=1,c=getchar();
while(c>47&&c<58)r=(r<<1)+(r<<3)+c-48,c=getchar();
return s?-r:r;
}inline int readint(){
char c=getchar();
int r=0;
bool s=0;
while((c<48||c>57)&&c!=45)c=getchar();
if(c==45)s=1,c=getchar();
while(c>47&&c<58)r=(r<<1)+(r<<3)+c-48,c=getchar();
return s?-r:r;
}inline void printll(ll x){
if(x<0){
putchar(45),printll(-x);
return;
}if(x>9)printll(x/10);
putchar(x%10+48);
}inline void printint(int x){
if(x<0){
putchar(45),printint(-x);
return;
}if(x>9)printint(x/10);
putchar(x%10+48);
}inline ll maxll(ll x,ll y){
return x<y?y:x;
}inline int maxint(int x,int y){
return x<y?y:x;
}inline ll minll(ll x,ll y){
return x<y?x:y;
}inline int minint(int x,int y){
return x<y?x:y;
}inline ll count(ll*s,ll*e,ll v){
ll r=0;
while(s<e){
if(*s==v)r++;
s++;
}return r;
}inline ll*lowerbound(ll*s,ll*e,ll v){
while(s<e){
ll*mid=s+((e-s)>>1);
if(*mid<v)s=mid+1;
else e=mid;
}return s;
}inline ll*upperbound(ll*s,ll*e,ll v){
while(s<e){
ll*mid=s+((e-s)>>1);
if(v<*mid)e=mid;
else s=mid+1;
}return s;
}inline string readstr(){
string s="";
char c=getchar();
while(c>0&&c!=9&&c!=10&&c!=13&&c!=32)s+=c,c=getchar();
return s;
}inline void printstr(string s){
for(char i:s)putchar(i);
}inline void readchrs(char*s){
*s=getchar();
while(*s>0&&*s!=9&&*s!=10&&*s!=13&&*s!=32)*(++s)=getchar();
*(++s)=0;
}inline void printchrs(char*s){
while(*s>0&&*s!=9&&*s!=10&&*s!=13&&*s!=32)putchar(*(s++));
}inline ll absll(ll x){
return x<0?-x:x;
}inline int absint(int x){
return x<0?-x:x;
}inline ll logll(ll x,ll e=2){
if(x<1||e<2)return 0;
ll r=1,l=0,a=0;
while(r<128)r*=e,l++;
while(r<=x)x/=r,a+=l;
while(e<=x)x/=e,a++;
return a;
}inline ll gcdll(ll x,ll y){
if(!(x&&y))return x+y;
ll s=__builtin_ctz(x|y);
x>>=__builtin_ctz(x);
y>>=__builtin_ctz(y);
while(y){
if(x>y)swap(x,y);
y-=x;
if(!y)break;
y>>=__builtin_ctz(y);
}return x<<s;
}inline void swapll(ll&x,ll&y){
x^=y^=x^=y;
}
};
using namespace skyy;