Блог пользователя backupkid

Автор backupkid, история, 107 минут назад, По-английски

Hi everyone!

I recently came across this problem and I’m not sure how to approach it efficiently. Any hints or ideas would be appreciated!


Problem Statement

Cyclic Divisibility

Given three positive integers $$$a, b, c$$$, we need to find the smallest positive integer $$$x$$$ such that:

$$$ a \cdot x \equiv 0 \pmod b $$$
$$$ b \cdot x \equiv 0 \pmod c $$$
$$$ c \cdot x \equiv 0 \pmod a $$$

---

Input

The first line contains an integer $$$T$$$ — the number of test cases ($$$1 \le T \le 10^5$$$).

Each of the next $$$T$$$ lines contains three integers $$$a, b, c$$$ ($$$1 \le a, b, c \le 10^6$$$).


Output

For each test case, print a single integer — the minimum value of $$$x$$$ satisfying the conditions.


Example

Input

2
4 6 10
12 34 56

Output

30
1428

Thanks for reading!
Any ideas or hints would be appreciated :)

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
67 минут назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In the example, I think you mistakenly wrote input again, pls fix it.

  • »
    »
    58 минут назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    ahh okay , my bad !!

»
57 минут назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Auto comment: topic has been updated by backupkid (previous revision, new revision, compare).

»
56 минут назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

I'm not sure but I think answer is lcm(lcm(lcm(a,b),lcm(b,c)),lcm(c,a))