CF1165D.Almost All Divisors

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

We guessed some integer number xx. You are given a list of almost all its divisors. Almost all means that there are all divisors except 11 and xx in the list.

Your task is to find the minimum possible integer xx that can be the guessed number, or say that the input data is contradictory and it is impossible to find such number.

You have to answer tt independent queries.

我们猜测了一个整数 xx。你被给定了它几乎全部的正因数列表。“几乎全部”意味着该列表中包含了除 11 和 xx 本身以外的所有正因数。

你的任务是找出最小可能的整数 xx,使得该列表恰好为其除 11 和 xx 外的所有正因数;或者判断输入数据自相矛盾,不存在满足条件的 xx。

你需要回答 tt 个相互独立的查询。

输入格式

The first line of the input contains one integer tt (1≤t≤251 \le t \le 25) — the number of queries. Then tt queries follow.

The first line of the query contains one integer nn (1≤n≤3001 \le n \le 300) — the number of divisors in the list.

The second line of the query contains nn integers d1,d2,…,dnd_1, d_2, \dots, d_n (2≤di≤1062 \le d_i \le 10^6), where did_i is the ii-th divisor of the guessed number. It is guaranteed that all values did_i are distinct.

输入的第一行包含一个整数 tt(1≤t≤251 \le t \le 25),表示查询次数。随后是 tt 组查询。

每组查询的第一行包含一个整数 nn(1≤n≤3001 \le n \le 300),表示列表中约数的个数。

每组查询的第二行包含 nn 个整数 d1,d2,…,dnd_1, d_2, \dots, d_n(2≤di≤1062 \le d_i \le 10^6),其中 did_i 是所猜测数字的第 ii 个约数。保证所有 did_i 的值互不相同。

输出格式

For each query print the answer to it.

If the input data in the query is contradictory and it is impossible to find such number xx that the given list of divisors is the list of almost all its divisors, print -1. Otherwise print the minimum possible xx.

对于每个查询,请输出其答案。

如果查询中的输入数据相互矛盾,即不存在满足条件的数 xx,使得给定的约数列表恰好是 xx 的“几乎所有”约数的列表,则输出 -1。否则,输出满足条件的最小可能的 xx。

输入输出样例

  • 输入#1

    2
    8
    8 2 12 6 4 24 16 3
    1
    2

    输出#1

    48
    4

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

首页