A - Happy Birthday! 4 Editorial by en_translator
If you are new to learning programming and do not know where to start, please try Problem A “Welcome to AtCoder” from practice contest. There you can find a sample code for each language.
Also, if you are not familiar with problems in programming contests, we recommend you to try some problems in “AtCoder Beginners Selection” (https://atcoder.jp/contests/abs).
If we assume that Takahashi’s age will become \(Z\) times Aoki’s age \(k\) years later \((k \geq 0)\), we have:
\[X+k=Z(Y+k).\]
We can deform this equation and solve for \(k\) to obtain:
\[X+k=YZ+Zk\]
\[(Z-1)k=X-YZ\]
\[k=\displaystyle\frac{X-YZ}{Z-1}\]
Since \(k\) must be a non-negative integer, the answer to the problem is Yes if and only if:
- \((X-YZ)\) is divisible by \(Z-1\), and
- \(X-YZ \geq 0\).
These two conditions can be checked by using an if statement.
The problem can be solved by appropriately implementing the procedure.
x, y, z = map(int, input().split())
if (x - y * z) % (z - 1) == 0 and x - y * z >= 0:
print("Yes")
else:
print("No")
posted:
last update: