I found out that using getchar_unlockedis a quick way to read input. I saw that the code was read in many places, but could not understand. Can someone help me figure out how to read using getchar_unlocked? Thank you in advance.
void scanint(int &x)
{
register int c = getchar_unlocked();
x = 0;
for(;(c<48 || c>57);c = getchar_unlocked())
;
for(;c>47 && c<58;c = getchar_unlocked())
{
x = (x<<1) + (x<<3) + c - 48;
}
}
I have seen many other codes. I do not particularly understand the purpose of shifting the number. Any help in this regard is appreciated.
source
share