CF1165D.Almost All Divisors
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
We guessed some integer number x. You are given a list of almost all its divisors. Almost all means that there are all divisors except 1 and x in the list.
Your task is to find the minimum possible integer x 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 t independent queries.
我们猜测了一个整数 x。你被给定了它几乎全部的正因数列表。“几乎全部”意味着该列表中包含了除 1 和 x 本身以外的所有正因数。
你的任务是找出最小可能的整数 x,使得该列表恰好为其除 1 和 x 外的所有正因数;或者判断输入数据自相矛盾,不存在满足条件的 x。
你需要回答 t 个相互独立的查询。
输入格式
The first line of the input contains one integer t (1≤t≤25) — the number of queries. Then t queries follow.
The first line of the query contains one integer n (1≤n≤300) — the number of divisors in the list.
The second line of the query contains n integers d1,d2,…,dn (2≤di≤106), where di is the i-th divisor of the guessed number. It is guaranteed that all values di are distinct.
输入的第一行包含一个整数 t(1≤t≤25),表示查询次数。随后是 t 组查询。
每组查询的第一行包含一个整数 n(1≤n≤300),表示列表中约数的个数。
每组查询的第二行包含 n 个整数 d1,d2,…,dn(2≤di≤106),其中 di 是所猜测数字的第 i 个约数。保证所有 di 的值互不相同。
输出格式
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 x that the given list of divisors is the list of almost all its divisors, print -1. Otherwise print the minimum possible x.
对于每个查询,请输出其答案。
如果查询中的输入数据相互矛盾,即不存在满足条件的数 x,使得给定的约数列表恰好是 x 的“几乎所有”约数的列表,则输出 -1。否则,输出满足条件的最小可能的 x。
输入输出样例
输入#1
2 8 8 2 12 6 4 24 16 3 1 2
输出#1
48 4
输入解题思路,AI测评打分。不知道怎么写?