I have a stupid doubt if in question we have given range of values upto 10^18 but the answer is accepted to be MODULO 10^9 + 7.
Then i have two choices:
- At each step i should take MODULO, despite the fact that number can be stored in long long int range.(shown by fun1)
- I should take MODULO only where the result is excepted to overflow range of data type.(shown by fun2)
which approach is correct and why ?
ll:long long int
void fun1(ll a,ll b)
void fun2(ll a,ll b)