C/C++中cin 用来读数据是最慢的,虽然可以自动识别,但是效率低下,在ACM题如果输入数据太大的话用cin肯定会超时,用scanf会比cin快些,但是还有一种输入外挂比scanf更快些,那就是用getchar()来读:
inline __int64 Read()
{
char ch = getchar();
int f = 1;
__int64 x = 0;
while(ch<'0' || ch>'9')
{
if(ch == '-') { f = -1; ch = getchar();}
}
while(ch<='9' && ch>='0')
{
x = x*10 + ch-'0';
ch = getchar();
}
return x*f;
}
很简单~