As limits of R is [1,10^9], so even (S+2D)*R^2 has the chance of integer over flow if R is 10^9 (long long int in c). So do we have to do (% 1000000007) each time? And is it required to print an empty line after each output ?

You cant ask that for an ongoing Contest. But yes, Its a property of modular arithmetic. and yes, you have to leave a line after each output.

1 Like