No.3307 Almost Equal
問題文最終更新日: 2025-10-04 23:08:36
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Show the original
yukicoder contest MMA Contest 020
(順位表)
の他の問題:
Problem Statement
You are given positive integers $A, B, C, D$. Output the number of positive integers $i$ that satisfy the following condition.
- $\displaystyle{\text{round} \left( i \times \frac{A}{B} \right) = \text{round} \left( i \times \frac{C}{D} \right)}$
-1.
Constraints
- All inputs are integers.
- $1 \leq A < B \leq 10^9$
- $1 \leq C < D \leq 10^9$
Input
$A \ B \ C \ D$
Output
Output the result in $1$ line.
Sample
Sample 1
Input
1 3 1 4
Output
7
For $i = {1, 2, 3, 4, 6, 7, 10}$, we have $\text{round} \left( \frac{i}{3} \right) = \text{round} \left( \frac{i}{4} \right)$.
Sample 2
Input
1 2 2 4
Output
-1
Sample 3
Input
216988846 221791262 433977693 443582525
Output
10243045170
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
sepa38