#P9401. [POI 2020/2021 R3] 收藏家 2 / Kolekcjoner Bajtemonów 2

[POI 2020/2021 R3] 收藏家 2 / Kolekcjoner Bajtemonów 2

Background

Translated from XXVIII Olimpiada Informatyczna - stage III Kolekcjoner Bajtemonów 2.

This is a sample judging problem.

Problem Description

You are given nn pairs of numbers. You need to make nn binary choices (choose one number from each pair), so that you end up with nn numbers, and maximize the gcd\gcd of these nn numbers.

Input Format

The first line contains a positive integer nn.

The next nn lines each contain two integers ai,bia_i, b_i.

Output Format

Output one number in one line: the maximum possible gcd\gcd.

4
5 7
10 15
13 20
7 5

5
2
18900 22050
14700 17640

7350
见附件
2

Hint

Constraints: for all testdata, 1n1061 \leq n \leq 10^6, 1ai5×1051 \leq a_i \leq 5 \times 10^5, 1bi<2631 \leq b_i < 2^{63}.

For the 4242 pts testdata, n5000n \leq 5000.

Translated by ChatGPT 5