快速读入挂

 
 1 int Scan()///输入外挂
 2 {
 3     int res=0,ch,flag=0;
 4     if((ch=getchar())=='-')
 5         flag=1;
 6     else if(ch>='0'&&ch<='9')
 7         res=ch-'0';
 8     while((ch=getchar())>='0'&&ch<='9')
 9         res=res*10+ch-'0';
10     return flag?-res:res;
11 }

 

 1 namespace IO{
 2     const int MAX = 4e7;                // 1e7 == 11000kb
 3     char buf[MAX]; int c, sz;           //预先缓冲到数组buf
 4     void begin(){
 5         c = 0;
 6         sz = fread(buf, 1, MAX, stdin);
 7     }
 8     inline bool read(int &t){
 9         while(c < sz && buf[c] != '-' && (buf[c] < '0' || buf[c] > '9')) c++;
10         if(c >= sz) return false;
11         bool flag = 0; if(buf[c] == '-') flag = 1, c++;
12         for(t = 0; c < sz && '0' <= buf[c] && buf[c] <= '9'; c++) t = t*10+buf[c]-'0';
13         if(flag) t=-t;
14         return true;
15     }
16 }
17 
18 int main()
19 {
20     IO::begin();
21     while(IO::read(N)){
22         for(int i = 1;i <= N; i++) IO::read(a[i].l);
23         for(int i = 1;i <= N; i++)IO::read(a[i].r);
24     }
25     return 0;
26 }

 

posted @ 2019-05-03 11:14  莜莫  阅读(416)  评论(0编辑  收藏  举报