They are the exact same code with only one difference.
In code 1 “mod” variable is declared as constexpr long long int
In code 2 “mod” variable is declared as long long int
In both the “mod” variable is initialised with value 1e9+7
But their runtime is very different.
code 1=> 0.26 sec
code 2=> 0.62 sec
So, the first question is why this happened?
I know a thing that using constexpr we can tell compiler a part to execute during compile time. So, that the time will not be considered in Runtime. I may be wrong, if so then please tell correct thing.
So, I tried to fill an array of factorial and its modular inverse in another array during compile time.
In custom test only it gave virtual memory exceeded. The size of both array each was 5e5.
But if I will store same thing during runtime it will run and it’s proof is above two codes.
So, second question is what is this virtual memory? How virtual memory exceeded different from memory limit exceeded (which generally gives SIGSEGV ).