307136: CF1307B. Cow and Friend
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Cow and Friend
题意翻译
## 题目描述 贝茜有太多朋友了。因为她是所有人最喜欢的牛。她的朋友兔兔在试着跳到贝茜所在的地方,那么他们就可以玩了。 更具体地,兔兔他想跳几步使得他能从 $(0,0)$ 跳到 $(x,0)$。他只想着在二维平面上从一个点跳到另一个点当且仅当两个点的欧几里得距离是他 $n$ 个喜欢的数中的其中一个,也就是 $a_1, a_2, \ldots a_n$。 兔兔最少要跳几步才能从 $(0,0)$ 跳到 $(x,0)$ 呢?兔兔不必跳到一个整数的坐标,换句话说,他可以跳到一个不是整数的坐标。可以证明,兔兔总可以到达他的终点。 重新在此声明,两个点的欧几里得距离可以使用公式算出,设两个点的坐标分别为 $x_1,y_1$ 以及 $x_2,y_2$,那么有公式 $\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}$。 如下图所示,如果兔兔喜欢的数是 $1$ 和 $3$的话,那么他可以跳两步从 $(0,0)$ 跳到 $(4,0)$。值得注意的是,这里还有别的方式使得他可以用 $2$ 步跳到 $(4,0)$ 的方法。 ![CF1307B Cow and Friend](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1307B/f7586d192526c0aed9ac1b72d0c3e07431d38d89.png) 图中的就是样例的第一个测试的示意图,两次跳的距离都是 $3$ -- 一个兔兔喜欢的数。换句话说,每一次兔兔都会选一个数 $a_i$,然后任意地跳到一个与这个点距离为 $a_i$ 的地方。 相同的数可以使用多次。 ## 输入格式 输入有多组数据。 第一行,一个整数 $t\ (1 \leq t \leq 1000)$。表示数据组数。 下面的 $2t$ 行,是 $t$ 组数据。 每组数据的第一行,有两个整数 $n,x$,表示喜欢的数的个数以及想要跳到的地方 $(0,x)$。其中 $1 \le n \le 10^5, 1 \le x \le 10^9$。 第二行是兔兔喜欢的整数,有 $n$ 个,依次是 $a_1, a_2, \ldots a_n$,这些数在同组数据中都不相同。 数据保证 $t$ 组数据中 $n$ 的总和都不会超过 $10^5$, ## 输出格式 对于每组数据,输出一个整数,表示最少要跳多少次才能到终点。题目描述
Bessie has way too many friends because she is everyone's favorite cow! Her new friend Rabbit is trying to hop over so they can play! More specifically, he wants to get from $ (0,0) $ to $ (x,0) $ by making multiple hops. He is only willing to hop from one point to another point on the 2D plane if the Euclidean distance between the endpoints of a hop is one of its $ n $ favorite numbers: $ a_1, a_2, \ldots, a_n $ . What is the minimum number of hops Rabbit needs to get from $ (0,0) $ to $ (x,0) $ ? Rabbit may land on points with non-integer coordinates. It can be proved that Rabbit can always reach his destination. Recall that the Euclidean distance between points $ (x_i, y_i) $ and $ (x_j, y_j) $ is $ \sqrt{(x_i-x_j)^2+(y_i-y_j)^2} $ . For example, if Rabbit has favorite numbers $ 1 $ and $ 3 $ he could hop from $ (0,0) $ to $ (4,0) $ in two hops as shown below. Note that there also exists other valid ways to hop to $ (4,0) $ in $ 2 $ hops (e.g. $ (0,0) $ $ \rightarrow $ $ (2,-\sqrt{5}) $ $ \rightarrow $ $ (4,0) $ ). ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1307B/f7586d192526c0aed9ac1b72d0c3e07431d38d89.png)Here is a graphic for the first example. Both hops have distance $ 3 $ , one of Rabbit's favorite numbers.In other words, each time Rabbit chooses some number $ a_i $ and hops with distance equal to $ a_i $ in any direction he wants. The same number can be used multiple times.输入输出格式
输入格式
The input consists of multiple test cases. The first line contains an integer $ t $ ( $ 1 \le t \le 1000 $ ) — the number of test cases. Next $ 2t $ lines contain test cases — two lines per test case. The first line of each test case contains two integers $ n $ and $ x $ ( $ 1 \le n \le 10^5 $ , $ 1 \le x \le 10^9 $ ) — the number of favorite numbers and the distance Rabbit wants to travel, respectively. The second line of each test case contains $ n $ integers $ a_1, a_2, \ldots, a_n $ ( $ 1 \le a_i \le 10^9 $ ) — Rabbit's favorite numbers. It is guaranteed that the favorite numbers are distinct. It is guaranteed that the sum of $ n $ over all the test cases will not exceed $ 10^5 $ .
输出格式
For each test case, print a single integer — the minimum number of hops needed.
输入输出样例
输入样例 #1
4
2 4
1 3
3 12
3 4 5
1 5
5
2 10
15 4
输出样例 #1
2
3
1
2