卡常模板
卡常模板,必背
1 #pragma GCC optimize(1) 2 #pragma GCC optimize(2) 3 #pragma GCC optimize(3) 4 #include<iostream> 5 #include<cstdio> 6 #include<ctime> 7 #include<cstdlib> 8 #include<cstring> 9 #include<algorithm> 10 #define Ri register int 11 #define sswap(x,y) x^=y^=x^=y; 12 template <class T> T mmin(T x,T y){return(x)<(y)?(x):(y);} 13 template <class T> T mmax(T x,T y){return(x)<(y)?(y):(x);} 14 template <class T> T lowbit(T x){return ((x)&(-(x)));} 15 typedef long long ll; 16 using namespace std; 17 namespace io{ 18 const int MT=5e7; 19 char buf[MT];ll c,sz; 20 void begin(){c=0;sz=fread(buf,1,MT,stdin);} 21 template<class T> 22 inline bool read(T &t) 23 { 24 while(c<sz&&buf[c]!='-'&&(buf[c]<'0'||buf[c]>'9'))c++; 25 if(c>=sz)return false; 26 bool flag=0;if(buf[c]=='-')flag=1,c++; 27 for(t=0;c<sz&&'0'<=buf[c]&&buf[c]<='9';c++)t=t*10+buf[c]-'0'; 28 if(flag==1)t=-t;return true; 29 } 30 } 31 template <typename _TpInt> 32 inline void write(_TpInt x) 33 { 34 if (x<0){ 35 putchar('-'); 36 write<_TpInt>(~x+1); 37 } 38 else { 39 if (x>9)write<_TpInt>(x/10); 40 putchar(x%10+'0'); 41 } 42 } 43 template <typename _ll> 44 inline void ...(_ll x) 45 {...} 46 int main(void) 47 { 48 io::begin(); 49 io::read(); 50 write(); 51 } 52