CF571E.Geometric Progressions

NOI/NOI+/CTSC

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Geometric progression with the first element a and common ratio b is a sequence of numbers a, ab, _ab_2, _ab_3, ....

You are given n integer geometric progressions. Your task is to find the smallest integer x, that is the element of all the given progressions, or else state that such integer does not exist.

首项为 aa、公比为 bb 的等比数列为一串数字:a, ab, ab2, ab3, …a,\ ab,\ ab^2,\ ab^3,\ \dots。

给定 nn 个整数等比数列。你的任务是找出最小的整数 xx,使得 xx 同时属于所有给定的等比数列;若不存在这样的整数,则说明其不存在。

输入格式

The first line contains integer (1 ≤ n ≤ 100) — the number of geometric progressions.

Next n lines contain pairs of integers a, b (1 ≤ a, b ≤ 109), that are the first element and the common ratio of the corresponding geometric progression.

第一行包含一个整数 $ n (( 1 \leq n \leq 100 $)—— 表示等比数列的个数。

接下来的 $ n $ 行,每行包含一对整数 $ a 、、 b (( 1 \leq a, b \leq 10^9 $),分别表示对应等比数列的首项与公比。

输出格式

If the intersection of all progressions is empty, then print  - 1, otherwise print the remainder of the minimal positive integer number belonging to all progressions modulo 1000000007 (109 + 7).

如果所有等差数列的交集为空,则输出 −1-1;否则输出属于所有等差数列的最小正整数对 10000000071000000007(即 109+710^9 + 7)取模的结果。

输入输出样例

  • 输入#1

    2
    2 2
    4 1

    输出#1

    4
  • 输入#2

    2
    2 2
    3 3

    输出#2

    -1

说明/提示

In the second sample test one of the progressions contains only powers of two, the other one contains only powers of three.

在第二个样例测试中,其中一个等差数列仅包含 2 的幂,另一个等差数列仅包含 3 的幂。

输入解题思路,AI测评打分。不知道怎么写?

首页