【題解】Codeforces 1307B. Cow and Friend

【題目敘述】http://codeforces.com/contest/1307/problem/B

#include <iostream>
using namespace std;
 
long long t, n, x, a, mx;
bool flag;
 
int main() {
    cin >> t;
    while (t--){
        cin >> n >> x;
        mx = 0;
        flag = false;
        for (int i = 0; i < n; i++){
            cin >> a;
            if (a == x) flag = true;
            else mx = max(mx, a);
        }
        if (flag) cout << 1 << "\n";
        else if (mx > x) cout << 2 << "\n";
        else cout << (x+mx-1)/mx << "\n";
    }
}
分享本文 Share with friends