有一些极端情况,用scanf会超时,用putchar
下面为读数字
void nextInt(int &x) //输入外挂 { do c=getchar(); while (c<'0'||c>'9'); x=c-'0'; while ('0'<=(c=getchar())&&c<='9') x=x*10+c-'0'; }
void Out(int a) //输出外挂 { if(a>9) Out(a/10); putchar(a%10+'0'); }
参考:
poj 1904(强连通分量+输入输出外挂)