We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
There is a very strange step in input/output 3. The transformation 4/((-2)/10) -> 40/(-2) does not make sense. It is arithmetically correct, but A) the reduction of double division into multiplication is not specified anywhere B) this does not match the behavior of most sane integer arithmetic evaluators (they evaluate strictly in parenthetical order) C) this requires either really weird AST manipulation or the use of non-standard number types to implement.
I suggest either A) clarifying the description to state that we're doing what essentially amounts to either doing arithmetic with rational number types or B) changing evaluation behavior to something reasonable (like what's used in basically every single programming language). In the standard case, it would be 4/((-2)/10) -> 4/(-1) -> -4.
Also, the description says to print the output mod 1,000,000,007 (p), not constrain all intermediate steps to p, so it is not at all clear that we are supposed to substitute division with multiplicative inversion mod p.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Expressions V2
You are viewing a single comment's thread. Return to all comments →
There is a very strange step in input/output 3. The transformation
4/((-2)/10)
->40/(-2)
does not make sense. It is arithmetically correct, but A) the reduction of double division into multiplication is not specified anywhere B) this does not match the behavior of most sane integer arithmetic evaluators (they evaluate strictly in parenthetical order) C) this requires either really weird AST manipulation or the use of non-standard number types to implement.I suggest either A) clarifying the description to state that we're doing what essentially amounts to either doing arithmetic with rational number types or B) changing evaluation behavior to something reasonable (like what's used in basically every single programming language). In the standard case, it would be
4/((-2)/10)
->4/(-1)
->-4
.Also, the description says to print the output mod 1,000,000,007 (p), not constrain all intermediate steps to p, so it is not at all clear that we are supposed to substitute division with multiplicative inversion mod p.