ABC175
I solved 3 questions and the rating increased slightly.
It's not clear to me that I only solved 3 questions, but those 3 questions were solved in 18 minutes, so I guess it's a light blue performance?
AtCoder problems, C is unknown difficulty.
https://gyazo.com/f4738f97644706bce47fd3a7fcb6e031
https://gyazo.com/f018626553faead2043227e811314934
Exactly the same as the official explanation.
Potential question, "How do you come up with that?"
Solve for small specific values, like X=5, D=2, etc.
While the absolute value of X is greater than D, it moves in the direction of decreasing
When small, it oscillates across the origin.
The number of cycles is 2, so look at the remainder of the number of cycles remaining divided by 2.
code:python
def solve(X, K, D):
X = abs(X)
a = X // D
if a >= K:
return X - K * D
r = X % D
K -= a
if K % 2 == 0:
return r
else:
return D - r
---
This page is auto-translated from /nishio/ABC175 using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I'm very happy to spread my thought to non-Japanese readers.