题解:CF1307B Cow and Friend
题目传送门
思路
考虑贪心。
先判断能不能一次整好跳过去,如果可以,输出
两次最长的可以跳到
代码:
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
int T;
cin >> T;
while(T --) {
int n, x;
cin >> n >> x;
int l = 0;
int res = 0;
for(int i = 0; i < n; i++) {
int temp;
cin >> temp;
if(x == temp) res = 1;
l = max(l, temp);
}
if(res == 1) {
cout << res << endl;
continue;
}
res = 2;
res = max(res, (x + l - 1) / l);
cout << res << endl;
}
}