CF560A.Currency System in Geraldion

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

A magic island Geraldion, where Gerald lives, has its own currency system. It uses banknotes of several values. But the problem is, the system is not perfect and sometimes it happens that Geraldionians cannot express a certain sum of money with any set of banknotes. Of course, they can use any number of banknotes of each value. Such sum is called unfortunate. Gerald wondered: what is the minimum unfortunate sum?

杰拉尔迪恩(Geraldion)是一座神奇的岛屿,杰拉尔德(Gerald)就住在那里。该岛拥有自己的一套货币系统,使用若干种面额的纸币。但问题在于,该系统并不完美,有时杰拉尔迪恩人无法用任意数量的各面额纸币组合出某个特定的金额。当然,每种面额的纸币可以使用任意多张。这样的金额被称为“不幸数”。杰拉尔德思考道:最小的不幸数是多少?

输入格式

The first line contains number n (1 ≤ n ≤ 1000) — the number of values of the banknotes that used in Geraldion.

The second line contains n distinct space-separated numbers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 106) — the values of the banknotes.

第一行包含一个整数 nn(1≤n≤10001 \leq n \leq 1000)—— Geraldion 所使用的纸币面值的种类数。

第二行包含 nn 个互不相同的、以空格分隔的整数 a1, a2, ..., ana_1,\,a_2,\,...,\,a_n(1≤ai≤1061 \leq a_i \leq 10^6)—— 各纸币的面值。

输出格式

Print a single line — the minimum unfortunate sum. If there are no unfortunate sums, print  - 1.

输出一行——最小的不幸和。如果没有不幸和,则输出 -1。

输入输出样例

  • 输入#1

    5
    1 2 3 4 5

    输出#1

    -1

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

首页