Alex_tz307

FAST CIN

Aug 16th, 2021
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. namespace FastRead {
  2.   const int Dim(50000);
  3.   char ibuf[Dim];
  4.   int ipos, ilen;
  5.  
  6.   char nc() {
  7.     if (ipos == ilen) {
  8.       ipos = 0;
  9.       ilen = fread(ibuf, 1, Dim, stdin);
  10.       if (!ilen)
  11.         return EOF;
  12.     }
  13.     return ibuf[ipos++];
  14.   }
  15.  
  16.   template<class T> void read(T& x) {
  17.     char ch;
  18.     int sgn = 1;
  19.     while (!isdigit(ch = nc()))
  20.       if (ch == '-')
  21.         sgn = -1;
  22.     x = ch - '0';
  23.     while (isdigit(ch = nc()))
  24.       x = x * 10 + (ch - '0');
  25.     x *= sgn;
  26.   }
  27. }
  28.  
  29. using namespace FastRead;
Advertisement
Add Comment
Please, Sign In to add comment