# Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Who doesn’t know about thanos the genius mad titan, who waste his life acquiring the infinity stones. He is close enough to discover the architectural value of power stone.

He found that the architectural value of power stone is **X** such that **X % M _{1} = A _{1}, X % M_{2} = A _{2}, … ,X % M_{n} = A _{n}** and

As the **X** can be very big find **X Modulo LCM(M _{1}, M_{2}, …, M_{n})**

Input starts with **N** representing the size of set **A, M**
Next two lines contain **N** Integers each. Representing set **A** and **M** respectively.

**Constraints:**

**1 ≤ N ≤ 10 ^{5}**

**1 ≤ M _{i} ≤ 40**

**N.B: Every constraints will be valid**

Print **X Modulo LCM(M _{1}, M_{2}, …, M_{n})** denoting the Architectural value of power stone, If such

Input | Output |
---|---|

3 1 2 4 2 3 5 | 29 |

73% Solution Ratio

Riaz_BSMRSTUEarliest,

TurinhstuFastest, 0.0s

TurinhstuLightest, 1.7 MB

dip_BRURShortest, 927B

Login to submit