E. Morrowindows

Codeforces
IDCF73E
Time2000ms
Memory256MB
Difficulty
mathnumber theory
English · Original
Chinese · Translation
Formal · Original
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_. ## Input 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. ## Output Output the fewest amount of modes required to uniquely determine amount of items in the inventory. If there is no solution output  - 1. [samples] ## Note 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.
Vasya 正在玩《上古卷轴 III:晨风》。他的背包中有大量物品,但物品大小没有限制。Vasya 不知道物品的准确数量,但他确信背包中的物品数量不少于 #cf_span[2] 件,且不多于 #cf_span[x] 件。游戏更新了一个新补丁,允许以 #cf_span[n] 种不同模式查看背包。在模式 #cf_span[i] 下,所有物品被分页显示,每页(除了可能的最后一页)恰好显示 #cf_span[ai] 件物品。此外,每种模式还会显示完整列表中的页数 #cf_span[bi]。太棒了!也许这些信息足以让 Vasya 确定物品的确切数量。更有趣的是,Vasya 最少需要选择多少种模式,才能确定背包中的物品数量? *Vasya 不能利用在某种模式下查看背包所获得的信息来选择后续操作。也就是说,Vasya 首先选定一组模式,然后一次性查看所有模式的返回结果,再据此推断物品数量。* 已知 #cf_span[ai] 和 #cf_span[x] 的值,并假设 Vasya 非常聪明,请判断他是否能唯一确定背包中的物品数量,以及在已知 #cf_span[ai]、#cf_span[x] 且能获得每种模式下对应的 #cf_span[bi] 值的前提下,他最少需要选择多少种模式? 第一行包含两个整数 #cf_span[n] 和 #cf_span[x](#cf_span[0 ≤ n ≤ 105, 2 ≤ x ≤ 109])。第二行包含 #cf_span[n] 个整数 #cf_span[ai](#cf_span[1 ≤ ai ≤ 109])。所有 #cf_span[ai] 中可能存在重复数值。 请输出唯一确定背包中物品数量所需的最少模式数。若无解,请输出 #cf_span[ - 1]。 在第二个例子中,Vasya 无法唯一确定物品数量,因为 3 件物品和 4 件物品都可以被显示在两页中。 ## Input 第一行包含两个整数 #cf_span[n] 和 #cf_span[x](#cf_span[0 ≤ n ≤ 105, 2 ≤ x ≤ 109])。第二行包含 #cf_span[n] 个整数 #cf_span[ai](#cf_span[1 ≤ ai ≤ 109])。所有 #cf_span[ai] 中可能存在重复数值。 ## Output 请输出唯一确定背包中物品数量所需的最少模式数。若无解,请输出 #cf_span[ - 1]。 [samples] ## Note 在第二个例子中,Vasya 无法唯一确定物品数量,因为 3 件物品和 4 件物品都可以被显示在两页中。
**Definitions** Let $ n \in \mathbb{Z}_{\geq 0} $ be the number of available display modes. Let $ x \in \mathbb{Z}_{\geq 2} $ be the upper bound on the number of items in the inventory. Let $ A = \{a_1, a_2, \dots, a_n\} \subseteq \mathbb{Z}_{\geq 1} $ be the set of page sizes (items per page) for each mode. Let $ S \subseteq \{1, 2, \dots, x\} $ be the set of possible total item counts (unknown, to be determined). For a given mode $ i $ with page size $ a_i $, if the total number of items is $ s \in S $, then the number of pages displayed is: $$ b_i(s) = \left\lceil \frac{s}{a_i} \right\rceil $$ Vasya selects a subset of modes $ I \subseteq \{1, 2, \dots, n\} $, and observes the corresponding page counts $ \{b_i(s) \mid i \in I\} $. **Constraints** 1. $ 0 \leq n \leq 10^5 $ 2. $ 2 \leq x \leq 10^9 $ 3. $ 1 \leq a_i \leq 10^9 $ for all $ i \in \{1, \dots, n\} $ 4. The true number of items $ s^* \in \{2, 3, \dots, x\} $ is fixed but unknown. **Objective** Find the minimum size of a subset $ I \subseteq \{1, \dots, n\} $ such that the mapping $$ s \mapsto \left( \left\lceil \frac{s}{a_i} \right\rceil \right)_{i \in I} $$ is injective over $ s \in \{2, 3, \dots, x\} $. If no such subset exists, output $ -1 $.
Samples
Input #1
2 4
2 3
Output #1
2
Input #2
1 4
2
Output #2
\-1
API Response (JSON)
{
  "problem": {
    "name": "E. Morrowindows",
    "description": {
      "content": "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",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF73E"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "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...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "Vasya 正在玩《上古卷轴 III:晨风》。他的背包中有大量物品,但物品大小没有限制。Vasya 不知道物品的准确数量,但他确信背包中的物品数量不少于 #cf_span[2] 件,且不多于 #cf_span[x] 件。游戏更新了一个新补丁,允许以 #cf_span[n] 种不同模式查看背包。在模式 #cf_span[i] 下,所有物品被分页显示,每页(除了可能的最后一页)恰好显示 #cf_spa...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}_{\\geq 0} $ be the number of available display modes.  \nLet $ x \\in \\mathbb{Z}_{\\geq 2} $ be the upper bound on the number of items in the inventory.  \nLet $ A ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments