CF915A.Garden

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Luba thinks about watering her garden. The garden can be represented as a segment of length k. Luba has got n buckets, the i-th bucket allows her to water some continuous subsegment of garden of length exactly a__i each hour. Luba can't water any parts of the garden that were already watered, also she can't water the ground outside the garden.

Luba has to choose one of the buckets in order to water the garden as fast as possible (as mentioned above, each hour she will water some continuous subsegment of length a__i if she chooses the i-th bucket). Help her to determine the minimum number of hours she has to spend watering the garden. It is guaranteed that Luba can always choose a bucket so it is possible water the garden.

See the examples for better understanding.

卢巴正在考虑给她的花园浇水。花园可以表示为一条长度为 kk 的线段。卢巴有 nn 个水桶,其中第 ii 个水桶每小时恰好能浇灌花园中一段长度为 aia_i 的连续子线段。卢巴不能给已经浇过水的区域再次浇水,也不能给花园范围以外的地面浇水。

卢巴必须从这 nn 个水桶中选择恰好一个,以尽可能快地完成整个花园的浇水(如前所述:若她选择第 ii 个水桶,则每小时可浇灌一段长度为 aia_i 的连续子线段)。请帮她确定完成整个花园浇水所需的最少小时数。题目保证:总存在至少一个水桶,使得用它能够完成整个花园的浇水。

参见样例以加深理解。

输入格式

The first line of input contains two integer numbers n and k (1 ≤ n, k ≤ 100) — the number of buckets and the length of the garden, respectively.

The second line of input contains n integer numbers a__i (1 ≤ a__i ≤ 100) — the length of the segment that can be watered by the i-th bucket in one hour.

It is guaranteed that there is at least one bucket such that it is possible to water the garden in integer number of hours using only this bucket.

输入的第一行包含两个整数 nn 和 kk(1 ≤ n, k ≤ 1001 ≤ n, k ≤ 100),分别表示水桶的数量和花园的长度。

输入的第二行包含 nn 个整数 aia_i(1 ≤ ai ≤ 1001 ≤ a_i ≤ 100),表示第 ii 个水桶每小时能够浇灌的区段长度。

保证至少存在一个水桶,使得仅使用该水桶便可在整数小时内完成对整个花园的浇灌。

输出格式

Print one integer number — the minimum number of hours required to water the garden.

输出一个整数——浇灌花园所需的最少小时数。

输入输出样例

  • 输入#1

    3 6
    2 3 5

    输出#1

    2
  • 输入#2

    6 7
    1 2 3 4 5 6

    输出#2

    7

说明/提示

In the first test the best option is to choose the bucket that allows to water the segment of length 3. We can't choose the bucket that allows to water the segment of length 5 because then we can't water the whole garden.

In the second test we can choose only the bucket that allows us to water the segment of length 1.

在第一个测试用例中,最佳选择是选用能够浇灌长度为 3 的区间的水桶。我们不能选用能够浇灌长度为 5 的区间的水桶,因为那样无法浇灌整个花园。

在第二个测试用例中,我们只能选用能够浇灌长度为 1 的区间的水桶。

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

首页