A8137 | Morrowindows
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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$ .
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$ .
输入格式
The first line contains two integers $n$ and $x$ ( $0<=n<=10^{5},2<=x<=10^{9}$ ). The second line contains integers $a_{i}$ ( $1<=a_{i}<=10^{9}$ ). Some numbers among all $a_{i}$ may be equal.
输出格式
Output the fewest amount of modes required to uniquely determine amount of items in the inventory. If there is no solution output $-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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted