CF571E.Geometric Progressions

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Geometric progression with the first element aa and common ratio bb is a sequence of numbers a,ab,ab2,ab3,...a,ab,ab^{2},ab^{3},... .

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

输入格式

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

Next nn lines contain pairs of integers a,ba,b ( 1<=a,b<=1091<=a,b<=10^{9} ), that are the first element and the common ratio of the corresponding geometric progression.

输出格式

If the intersection of all progressions is empty, then print 1-1 , otherwise print the remainder of the minimal positive integer number belonging to all progressions modulo 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.

首页