Cow and Friend
程序员文章站
2022-04-30 23:45:08
...
题意:牛牛有N个喜欢的数,他想从坐标原点跳到(x,0)点,他每次跳跃的距离只能的他喜欢的数请问从原点到X最少跳几次。
思路:每次都跳最大的步数如果不能直接跳完,最后2步走折线。
#include<map>
#include<iostream>
#include<algorithm>
#define MAXX 100005
#define SIS std::ios::sync_with_stdio(false)
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int MAX = 2e5 + 5;
const int mod = 1e9 + 7;
//const double PI = 3.141592653589793238462643383279;
const double PI = 3.1415926535;
const double esp = 1e-10;
ll pow_mod(ll a, ll b)
{
ll res = 1;
while (b > 0)
{
if (b & 1)
{
res = res * a % mod;
}
a = a * a % mod;
b >>= 1;
}
return res % mod;
}
int a[1000005];
map<int, int> mp;
int main() {
int t;
cin >> t;
while (t--) {
int n, d;
mp.clear();
cin >> n >> d;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
mp[a[i]] = 1;
}
sort(a + 1, a + n + 1);
if (mp[d]) {
cout << 1 << endl;
}
else
{
cout << max(2, (d + a[n] -1)/ a[n]) << endl;
}
}
return 0;
}
推荐阅读
-
P5200 [USACO19JAN]Sleepy Cow Sorting
-
LuoguP3069 【[USACO13JAN]牛的阵容Cow Lineup
-
poj3045 Cow Acrobats (思维,贪心)
-
HDU - 3823 Prime Friend(欧拉筛+思维)
-
POJ 3278 Catch That Cow(BFS)
-
POJ 3278 Catch That Cow 【bfs+队列】
-
最短路 Silver Cow Party
-
【洛谷】P1821 [USACO07FEB] Cow Party S(单源最短路)
-
Silver Cow Party(最短路)
-
kuangbin最短路专题Silver Cow Party (POJ - 3268)