PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000054. Chu kỳ trúng thưởng (Jackpot)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Chu kỳ trúng thưởng (Jackpot)
Jackpot
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
A slot machine has w wheels. Wheel i shows the jackpot symbol periodically, once every p_i plays, with all wheels initially aligned at play zero. Find the smallest positive number of plays until all wheels show the jackpot symbol simultaneously again. If it exceeds one billion, print the exact phrase More than a billion.
Input
First line: w. Second line: w positive integers p_i.
Output
The positive common period, or the exact string More than a billion. if it exceeds 10^9.
Subtasks
- Subtask 1 (20 points): , .
- Subtask 2 (30 points): , .
- Subtask 3 (50 points): , .
Examples
Input
3
10 6 15
Output
30
Explanation
The smallest positive common multiple of 10, 6, and 15 is 30.