CF73E.Morrowindows
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Vasya plays The Elder Trolls III: Morrowindows. He has a huge list of items in the inventory, however, there is no limits on the size of things. Vasya does not know the total amount of items but he is sure that are not more than x and not less than 2 items in his inventory. A new patch for the game appeared to view inventory in n different modes. Displaying in mode i is a partition of all inventory items on pages, each of which (except for maybe the last one) shows exactly a__i items. In addition, each mode shows how many pages b__i is in a complete list. Great! Perhaps this information will be enough for Vasya to find the required number. Moreover, it is very interesting, what is the fewest number of modes in which Vasya can see inventory to determine the number of items in it?
Vasya cannot use the information that was received while looking on inventory in some mode for selection of next actions. I. e. Vasya chooses some set of modes first, and then sees all the results and determines the size.
Knowing the number of a__i, x and assuming that Vasya is very smart, check whether he can uniquely determine the number of items in his inventory, and how many modes he will need to do that if he knows numbers a__i, x and he is able to know number b__i after viewing items in mode i.
瓦西娅正在玩《上古巨魔3:晨光之窗》。他的物品栏中拥有大量物品,但物品的体积没有限制。瓦西娅并不知道物品总数,但他确信物品总数至多为 x,且至少为 2 件。游戏新发布了一个补丁,允许以 n 种不同的模式查看物品栏。在第 i 种模式下,所有物品被划分为若干页,其中每页(除可能的最后一页外)恰好显示 ai 件物品;此外,该模式还会显示完整列表共包含 bi 页。太棒了!这些信息或许足以让瓦西娅确定物品的确切数量。更有趣的是:瓦西娅最少需要查看多少种模式,才能唯一确定物品总数?
瓦西娅无法利用在某一种模式下查看物品栏所获得的信息来决定后续操作。换言之,瓦西娅必须首先选定一组模式,然后一次性观察所有这些模式的显示结果(即所有对应的 bi 值),再据此推断出物品总数。
已知各 ai 的值、上限 x,并假设瓦西娅极其聪明,请判断他是否能唯一确定物品总数;若可以,他最少需要查看多少种模式?(他知晓所有 ai 和 x,且在选择第 i 种模式后,能获知对应显示的页数 bi。)
输入格式
The first line contains two integers n and x (0 ≤ n ≤ 105, 2 ≤ x ≤ 109). The second line contains integers a__i (1 ≤ a__i ≤ 109). Some numbers among all a__i may be equal.
第一行包含两个整数 n 和 x(0 ≤ n ≤ 105,2 ≤ x ≤ 109)。第二行包含整数 ai(1 ≤ ai ≤ 109)。所有 ai 中可能存在相等的数。
输出格式
Output the fewest amount of modes required to uniquely determine amount of items in the inventory. If there is no solution output - 1.
输出唯一确定库存中物品数量所需的最少模数个数。若无解,则输出 -1。
输入输出样例
输入#1
2 4 2 3
输出#1
2
输入#2
1 4 2
输出#2
-1
说明/提示
In the second example Vasya is not able to determine items count uniquely because 3 items, as well as 4 items, can be displayed on two pages.
在第二个例子中,瓦西娅无法唯一确定物品数量,因为 3 个物品和 4 个物品均可以显示在两页上。
输入解题思路,AI测评打分。不知道怎么写?