Is it safe to replace “a/(b*c)” with “a/b/c” when using integer-division?
问题 Is it safe to replace a/(b*c) with a/b/c when using integer-division on positive integers a,b,c , or am I at risk losing information? I did some random tests and couldn't find an example of a/(b*c) != a/b/c , so I'm pretty sure it's safe but not quite sure how to prove it. Thank you. 回答1: Mathematics As mathematical expressions, ⌊a/(bc)⌋ and ⌊⌊a/b⌋/c⌋ are equivalent whenever b is nonzero and c is a positive integer (and in particular for positive integers a , b , c ). The standard reference