当前位置:网站首页>Super fast reading in OI

Super fast reading in OI

2022-06-24 07:36:00 Hard working Lao Zhou

Super fast reading

Use getchar() To read . But only numbers can be read .

Code implementation

template <typename T>
inline T read() {
    
    T x = 0, f = 1;
    char ch = getchar();
 
    while (!isdigit(ch)) {
    
        if(ch=='-') {
    
            f = -1;
            ch = getchar();
        }
    }
 
    while (isdigit (ch)) {
    
          x = x * 10 + (ch ^ 48);
          ch = getchar();
    }
 
    return x * f;
}

Usage method

int T=read<int>();
long long x=read<long long>();
原网站

版权声明
本文为[Hard working Lao Zhou]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202211619274471.html