i found this definition of CPP array in and competitive programming editorial
long long s1[1<<10][1<<10],s2[1<<10][1<<10]
why it is written like this we can simply write it like
s1[1024][1024]
is there any reason behind this ?
i found this definition of CPP array in and competitive programming editorial
long long s1[1<<10][1<<10],s2[1<<10][1<<10]
why it is written like this we can simply write it like
s1[1024][1024]
is there any reason behind this ?
On
Constant bit shifts such as 1u << N are generally written to emphasise that the number is the Nth power of 2.
"Magic numbers" should be avoided, and small numbers like 1 and 10 are "less magical" than large numbers. I would still recommend using a named constant to clarify why 10 was used specifically.
1<<10is a shorthand for "Bit 10 is set, all other bits are zero". You find this construct very often around lowlevel code, where powers of 2 or bits are important.1<<10 == 0x400 == 010000000000