You don’t need power, just three basic log properties
log(a^b) = b*log(a)
log(a/b)= log(a) - log(b)
log(a*b)= log(a) + log(b)
Use them on the expression to get it into a one line formula which doesn’t need powers but logarithms
You don’t need power, just three basic log properties
log(a^b) = b*log(a)
log(a/b)= log(a) - log(b)
log(a*b)= log(a) + log(b)
Use them on the expression to get it into a one line formula which doesn’t need powers but logarithms
Fantastic. I studied it in detail. From a debug perspective, can you explain the purpose of assert(cin) in the last line?
It’s just to ensure that I haven’t accidentally tried to read more input than exists, or e.g. tried to read a string as an int
or somesuch - something that has bitten me a few times in the past
Edit:
Also helps to make sure that my testcase generator generates the right amount of stuff and of the right type.
Thanks for the explanation! Would you mind if I mimic some elements of your style, since emulation is the highest form of adulation!
I would be honoured Please take anything you want
Edit:
I gabbled on about my process here, and included the code template I usually use. Bear in mind that I don’t do short contests, though - the process really wouldn’t be suitable for those
Fantastic. Good practices to be learnt!