QOJ.ac

QOJ

時間限制: 3.0 s 記憶體限制: 512 MB 總分: 100 可 Hack ✓

#10521. 最小LCM

统计

3つの正整数 $a, b, k$ が与えられます。$x$ および $y$ がいずれも $k$ 以下の非負整数であるとき、$\text{LCM}(a + x, b + y)^\dagger$ の最小値を求めてください。

$^\dagger \text{LCM}(a, b)$ は $a$ と $b$ の最小公倍数を表します。例えば、$\text{LCM}(5, 7) = 35$、$\text{LCM}(10, 6) = 30$ です。

入力

各テストファイルには複数のテストケースが含まれます。1行目にテストケースの数 $T$ ($1 \le T \le 10^4$) が与えられます。各テストケースの形式は以下の通りです。

1行目に3つの整数 $a, b, k$ ($1 \le a, b, k \le 10^{14}$) が与えられます。

各テストファイルにおいて、$\max(a, b) > 10^5$ を満たすテストケースは最大で1つであることが保証されています。

出力

各テストケースについて、答えを1行に出力してください。

入出力例

入力 1

6
3 8 4
13 7 4
1 1 1
4 9 2
2 101 100
99999999999998 100000000000000 1

出力 1

8
14
1
10
101
4999999999999900000000000000

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.