#P10570. [JRKSJ R8] 网球

    ID: 11989 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>数学2024洛谷原创O2优化洛谷月赛

[JRKSJ R8] 网球

Background

Baseball is orange Tennis is green. Tennis is rising, tennis is falling.

And you never meet the people, you never shake their hands, you never hear their story or tell yours.
But somehow in the act of making something with a great deal of care and love, something's transmitted there.

Problem Description

You have two gears meshed together. You want that every time gear A rotates aa turns, gear B rotates exactly bb turns.

Because of precision requirements, each gear must have at least cc teeth. Find the minimum possible value of the sum of the numbers of teeth of gear A and gear B.

Input Format

This problem has multiple test cases.

The first line contains an integer TT describing the number of test cases. For each test case:

  • One line with three integers a,b,ca, b, c.

Output Format

For each test case, output one integer per line, representing the answer.

3
2 3 4
4 8 5
5 2 8

10
15
28

Hint

Sample Explanation

  • For the first test case, the optimal solution is that gear A has 66 teeth and gear B has 44 teeth, so the answer is 4+6=104 + 6 = 10.
  • For the second test case, the optimal solution is that gear A has 1010 teeth and gear B has 55 teeth, so the answer is 10+5=1510 + 5 = 15.
  • For the third test case, the optimal solution is that gear A has 88 teeth and gear B has 2020 teeth, so the answer is 8+20=288 + 20 = 28.

Constraints and Notes

This problem uses bundled testdata.

Let v=max(a,b,c)v = \max(a, b, c).

  • Subtask 0 (13 pts): v20v \leq 20.
  • Subtask 1 (13 pts): v5000v \leq 5000.
  • Subtask 2 (20 pts): v106v \leq 10^6.
  • Subtask 3 (54 pts): No special restrictions.

For all testdata, it is guaranteed that 1T8×1031 \leq T \leq 8\times 10^3 and 1a,b,c1091 \leq a, b, c \leq 10^9.

Input Format

Output Format

Translated by ChatGPT 5