快读一
inline int read ( ) {
int f= 1 , x= 0 ; char c= getchar ( ) ;
while ( ! isdigit ( c) ) {
if ( c== '-' ) f= - 1 ; c= getchar ( ) ; }
while ( isdigit ( c) ) {
x= ( x<< 3 ) + ( x<< 1 ) + ( c^ 48 ) ; c= getchar ( ) ; }
x *= f; return x;
}
快读二
typedef long long LL;
# define gc pa== pb&& ( pb= ( pa= buf) + fread ( buf, 1 , 100000 , stdin ) , pa== pb) ? EOF : * pa++
static char buf[ 100000 ] , * pa ( buf) , * pb ( buf) ;
inline LL readint ( ) {
LL x= 0 ; char c= gc;
while ( c< '0' || c> '9' ) c= gc;
for ( ; c>= '0' && c<= '9' ; c= gc) x= x* 10 + ( c& 15 ) ;
return x;
}
快读三
template < class T > inline
void read ( T & x)
{
x = 0 ; int f = 1 ; char c = getchar ( ) ;
while ( ! isdigit ( c) ) {
if ( c == '-' ) f = - 1 ; c = getchar ( ) ; }
while ( isdigit ( c) ) x = ( x << 3 ) + ( x << 1 ) + ( c ^ 48 ) , c = getchar ( ) ;
x *= f;
}
快读(long long)
ll read ( ) {
ll x= 0 , f= 1 ;
char ch= getchar ( ) ;
while ( ch< '0' || ch> '9' ) {
if ( ch== '-' ) f= - 1 ; ch= getchar ( ) ; }
while ( ch>= '0' && ch<= '9' ) {
x= x* 10 + ch- '0' ; ch= getchar ( ) ; }
return x* f;
}
快输
inline void print ( int x) {
if ( x< 0 ) {
putchar ( '-' ) ; x= - x; }
if ( x> 9 ) print ( x/ 10 ) ;
putchar ( x% 10 + 48 ) ;
}
直接把 cin
和 cout
、endl
改成快速
# include <fstream>
# include <iostream>
namespace Fast_I {
char * _Buf, * _Start_ptr, * _End_ptr;
std:: streambuf* inbuf;
unsigned int Size;
bool _Ok;
struct Fast_Istream {
operator bool ( ) {
return _Ok; }
Fast_Istream ( std:: streambuf* , unsigned int ) ;
Fast_Istream ( unsigned int ) ;
Fast_Istream ( const char * , unsigned int ) ;
Fast_Istream& operator >> ( char & ) ;
Fast_Istream& operator >> ( char * ) ;
Fast_Istream& operator >> ( bool & ) ;
Fast_Istream& operator >> ( short & ) ;
Fast_Istream& operator >> ( int & ) ;
Fast_Istream& operator >> ( long & ) ;
Fast_Istream& operator >> ( long long & ) ;
Fast_Istream& operator >> ( unsigned short & ) ;
Fast_Istream& operator >> ( unsigned int & ) ;
Fast_Istream& operator >> ( unsigned long & ) ;
Fast_Istream& operator >> ( unsigned long long & ) ;
Fast_Istream& operator >> ( float & ) ;
Fast_Istream& operator >> ( double & ) ;
Fast_Istream& operator >> ( long double &