text
stringlengths 49
983k
|
|---|
#include <bits/stdc++.h>
using namespace std;
int binarySearch(long long int arr[], long long int l, long long int r,
long long int x) {
if (r >= l) {
long long int mid = l + (r - l) / 2;
if (arr[mid] == x) return mid;
if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x);
return binarySearch(arr, mid + 1, r, x);
}
return -1;
}
int main() {
ios_base::sync_with_stdio(false);
long long int t;
cin >> t;
while (t--) {
long long int n, x;
cin >> n >> x;
long long int a[n];
for (long long int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
long long int ans = 0;
if (binarySearch(a, 0, n - 1, x) != -1) {
ans = 1;
} else {
if (x % a[n - 1] == 0) {
ans = x / a[n - 1];
} else {
if (x / a[n - 1] == 0) {
ans++;
}
ans += x / a[n - 1] + 1;
}
}
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long n, x, i, j = 2, ans = pow(10, 12), f = 0;
cin >> n >> x;
long long a[n];
for (i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == x) f = 1;
}
sort(a, a + n);
double k;
k = a[n - 1];
ans = ceil(x / k);
if (f == 1)
cout << 1 << endl;
else
cout << max(j, ans) << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
const long long linf = 0x3f3f3f3f3f3f3f3f;
set<int> s;
int v[100100];
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n, x;
scanf("%d%d", &n, &x);
for (int i = 0; i < n; i++) scanf("%d", &v[i]), s.insert(v[i]);
int menor = inf;
for (int i = 0; i < n; i++) {
int aux = x / v[i];
if (x % v[i]) {
if (aux)
aux++;
else
aux += 2;
}
menor = min(menor, aux);
}
printf("%d\n", menor);
s.clear();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int t;
int a[100000 + 10];
int n, x;
void solve() {
cin >> n >> x;
for (int i = 1; i <= n; i++) cin >> a[i];
int maxx = -1;
bool flag = false;
for (int i = 1; i <= n; i++) {
if (maxx < a[i]) maxx = a[i];
if (x == a[i]) flag = true;
}
if (flag)
cout << 1 << endl;
else
cout << max(2, (x + maxx - 1) / maxx) << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> t;
while (t--) solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long p) {
long long res = 1;
x = x % p;
while (y > 0) {
if (y & 1) res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
const long long mod = 1e9 + 7;
bool is(long long n) { return (ceil(log2(n)) == floor(log2(n))); }
bool q(const pair<long long, long long> &a,
const pair<long long, long long> &b) {
if (a.second == b.second) return a.first < b.first;
return a.second < b.second;
}
bool q2(const pair<long long, long long> &a,
const pair<long long, long long> &b) {
if (a.first == b.first) return a.second > b.second;
return a.first > b.first;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
long long t = 1, n, x;
cin >> t;
while (t--) {
cin >> n >> x;
long long a[n];
bool first = false;
for (long long i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == x) first = true;
}
if (first) {
cout << 1 << endl;
continue;
}
sort(a, a + n);
if (a[n - 1] >= x / 2 + x % 2) {
cout << 2 << endl;
continue;
}
long long in = n - 1;
long long ans = x / a[in] + (x % a[in] != 0), c = ans;
while (in >= 0) {
c = x / a[in] + (x % a[in] != 0);
ans = min(ans, c);
in--;
}
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const long long int inf = 1e18 + 1e17;
void solve() {
int n, d;
cin >> n >> d;
int arr[n];
for (int i = 0; i < n; i++) cin >> arr[i];
sort(arr, arr + n);
int ans = 1e9;
for (int i = n - 1; i >= 0; i--) {
if (arr[i] > d)
ans = 2;
else if (arr[i] == d)
ans = 1;
else if (arr[i] < d)
ans = min(d % arr[i] == 0 ? d / arr[i] : d / arr[i] + 1, ans);
}
cout << ans << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long int tc, n, x;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
cin >> tc;
while (tc) {
cin >> n >> x;
long long int t;
vector<long long int> a;
for (int i = 0; i < n; ++i) {
cin >> t;
a.push_back(t);
}
sort(a.begin(), a.end());
int count = 0;
if (a[n - 1] <= x) {
count = ceil((double)x / (double)a[n - 1]);
} else {
count = 2;
}
for (int i = 0; i < n; ++i) {
if (a[i] == x) {
count = 1;
break;
}
}
cout << count << "\n";
tc--;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
const int MOD = 1000000007;
const int INF = 1000000010;
mt19937 gen(41);
int a[N];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
int n, x;
cin >> n >> x;
int Max = 0;
bool h = false;
for (int i = 0; i < n; ++i) {
cin >> a[i];
if (x == a[i]) h = true;
Max = max(Max, a[i]);
}
if (h)
cout << 1 << '\n';
else
cout << max(2, x / Max + bool(x % Max)) << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
int n, x;
int a[100005];
while (t--) {
bool same = false;
bool bigger = false;
cin >> n >> x;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == x) same = true;
if (a[i] > x) bigger = true;
}
if (same) {
cout << 1 << endl;
continue;
}
if (bigger) {
cout << 2 << endl;
continue;
}
sort(a, a + n);
int biggest = a[n - 1];
if (biggest * 2 >= x) {
cout << 2 << endl;
continue;
}
if (x % biggest == 0) {
cout << x / biggest << endl;
continue;
}
int count = 2;
count += (x / biggest) - 1;
cout << count << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int T, x, n, a, hav;
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d%d", &n, &x);
a = hav = 0;
for (int i = 1, r; i <= n; i++) {
scanf("%d", &r);
a = max(a, r);
if (r == x) hav = 1;
}
if (hav)
printf("1\n");
else if (a <= x)
printf("%d\n", (x - 1) / a + 1);
else
printf("2\n");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int t;
cin >> t;
while (t--) {
long long int n, dist;
cin >> n >> dist;
long long int arr[n];
for (long long int i = 0; i < n; ++i) {
cin >> arr[i];
}
sort(arr, arr + n);
long long int ans = INT_MAX;
for (long long int i = 0; i < n; ++i) {
if (dist % arr[i] == 0) {
ans = min(ans, dist / arr[i]);
}
}
for (long long int i = n - 1; i >= 0; --i) {
if (arr[i] > dist) {
long long int temp = 2;
ans = min(ans, temp);
break;
} else {
long long int temp = (arr[i] + dist - 1) / arr[i];
ans = min(ans, temp);
break;
}
}
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll INF = 4e18;
const int N = 5e5 + 5;
int main() {
int t;
cin >> t;
while (t--) {
ll n, x;
cin >> n >> x;
vector<ll> a(n);
ll mx = -INF, f = 0;
for (auto &i : a) {
cin >> i;
mx = max(mx, i);
if (i == x) {
f = 1;
}
}
if (f) {
cout << 1 << '\n';
} else {
cout << max(x / mx + (x % mx != 0), 2LL) << '\n';
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int q;
scanf("%d", &q);
while (q--) {
int n, a, i, x, ans = 0;
scanf("%d %d", &n, &x);
int ara[n];
map<int, int> mp;
for (i = 0; i < n; i++) {
scanf("%d", &ara[i]);
mp[ara[i]] = 1;
}
sort(ara, ara + n);
a = ara[n - 1];
if (mp[x] == 1) {
printf("1\n");
continue;
}
ans = x / a;
if (x % a != 0) {
ans++;
}
if (x < a) {
ans++;
}
printf("%d\n", ans);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
long long n, x;
cin >> n >> x;
long long a[n];
for (long long i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
long long m = a[n - 1];
long long ans;
if (x % m == 0)
ans = x / m;
else if (m > x) {
int k = 0;
for (long long i = 0; i < n; i++) {
if (a[i] == x) {
ans = 1;
k = 1;
break;
}
}
if (k == 0) ans = 2;
} else if (x % m != 0 && m < x) {
ans = x / m + 1;
}
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long int n, x;
cin >> n >> x;
long long int arr[n];
long long int maxii = INT_MIN;
int flag = 0;
for (int i = 0; i < n; i++) {
cin >> arr[i];
if (arr[i] == x) flag = 1;
maxii = max(maxii, arr[i]);
}
if (flag == 1) {
cout << 1 << endl;
continue;
}
if (maxii > x) {
cout << 2 << endl;
continue;
}
cout << (x % maxii ? x / maxii + 1 : x / maxii) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main() {
int q;
cin >> q;
for (int j = 0; j < q; j++) {
int n, x;
cin >> n >> x;
int a[n];
bool have = false;
int mx = -INT_MAX;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (x == a[i]) have = true;
if (a[i] > mx) mx = a[i];
}
if (have == true) {
cout << 1 << endl;
} else if (mx > x || mx > (x / 2)) {
cout << 2 << endl;
} else {
if (x % mx == 0) {
cout << (x / mx) << endl;
} else {
cout << (x / mx) + 1 << endl;
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long ROMAN, FRUTISRK, ROMA, KOROBOV, KOROB;
long long min(long long a, long long b) { return (a < b ? a : b); }
long long max(long long a, long long b) { return (a > b ? a : b); }
int main() {
cin >> ROMAN;
while (ROMAN--) {
KOROBOV = 1e9;
cin >> FRUTISRK >> ROMA;
for (int i = 0; i < FRUTISRK; i++) {
cin >> KOROB;
if (KOROB == ROMA) {
KOROBOV = 1;
} else if (KOROB > ROMA) {
KOROBOV = min(KOROBOV, 2);
} else {
KOROBOV = min(KOROBOV, ROMA / KOROB + (ROMA % KOROB != 0));
}
}
cout << KOROBOV << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
int n;
int x;
while (t--) {
cin >> n >> x;
int a[n];
int flag = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == x) flag = 1;
}
if (flag == 1) {
cout << 1 << endl;
} else {
sort(a, a + n);
if (a[n - 1] >= ceil((float)x / 2)) {
cout << 2 << endl;
} else {
if (x % a[n - 1] == 0) {
cout << x / a[n - 1] << endl;
} else
cout << (x / a[n - 1]) + 1 << endl;
}
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int n, x;
int a[100005];
int main(void) {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int ntest;
cin >> ntest;
while (ntest--) {
cin >> n >> x;
for (int i = 1; i <= n; ++i) cin >> a[i];
sort(a + 1, a + 1 + n);
int ans = 1e9 + 7;
for (int i = 1; i <= n; ++i)
if (x == a[i]) ans = 1;
if (ans == 1) {
cout << ans << '\n';
continue;
}
int hops = x / a[n];
if (hops <= 1) {
cout << 2 << '\n';
continue;
}
ans = hops + 1;
x -= a[n] * (hops - 1);
for (int i = 1; i <= n; ++i)
if (x == a[i]) ans = hops;
cout << ans << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
template <class T>
inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
using namespace std;
int main() {
long long t;
scanf("%lld", &t);
while (t--) {
long long n, x;
scanf("%lld %lld", &n, &x);
vector<long long> a(n);
for (long long i = 0; i < n; i++) scanf("%lld", &a[i]);
sort(a.begin(), a.end());
if (binary_search(a.begin(), a.end(), x)) {
puts("1");
continue;
}
reverse(a.begin(), a.end());
if (a[0] > x) {
puts("2");
continue;
}
long long res = (x + a[0] - 1) / a[0];
printf("%lld\n", res);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1, c = getchar();
while (!isdigit(c)) {
if (c == '-') f = -1;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f == 1 ? x : -x;
}
const int N = 1e5 + 4;
int n, X, a[N];
inline void solve() {
n = read();
X = read();
for (int i = 1; i <= n; i++) a[i] = read();
sort(a + 1, a + n + 1);
if (a[n] < X) {
cout << (X + a[n] - 1) / a[n] << "\n";
} else {
for (int i = 1; i <= n; i++)
if (X == a[i]) {
puts("1");
return;
}
puts("2");
}
}
int main() {
for (int T = read(); T--;) solve();
return (0 - 0);
}
|
#include <bits/stdc++.h>
const int mod = 998244353;
using namespace std;
int a[500000];
int main() {
int t;
cin >> t;
while (t--) {
int n;
long long x;
cin >> n >> x;
int ans = -1;
for (int i = 0; i < n; ++i) {
cin >> a[i];
if (a[i] == x) {
ans = 1;
}
}
if (x == 0) ans = 0;
if (ans == -1) {
sort(a, a + n);
ans = x / a[n - 1];
if (a[n - 1] * ans < x) ans++;
ans = max(2, ans);
}
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int a[N];
int main() {
int t;
cin >> t;
while (t--) {
int n, x;
cin >> n >> x;
int ok = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (a[i] == x) {
ok = 1;
}
}
if (ok == 1) {
cout << 1 << '\n';
continue;
}
sort(a + 1, a + 1 + n);
int b = a[n];
if (x < b) {
cout << 2 << '\n';
} else if (x % b == 0) {
cout << x / b << '\n';
} else {
cout << x / b + 1 << '\n';
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long dp[4100][4100];
long long m;
long long factor[1000001];
long long fact(long long n);
long long power(long long a, long long b, long long f1) {
long long x = 1, y = a;
while (b > 0) {
if (b % 2 == 1) {
x = (x * y);
if (x > f1) x %= f1;
}
y = (y * y);
if (y > f1) y %= f1;
b /= 2;
}
return x;
}
long long fact(long long n, long long f1) { return power(n, f1 - 2, f1); }
long long nCr(long long n, long long r, long long f1) {
return (factor[n] * ((fact(factor[r], f1) * fact(factor[n - r], f1)) % f1)) %
f1;
}
template <typename T>
T ma(T x, T y) {
return (x > y) ? x : y;
}
bool subset(vector<long long> &v, long long n, long long sum) {
if (sum == 0) return true;
if (n == 0) return false;
if (v[n - 1] > sum) {
return subset(v, n - 1, sum);
}
return subset(v, n - 1, sum) || subset(v, n - 1, sum - v[n - 1]);
}
long long ans1 = 0;
long long ans2 = 0;
long long quesc(long long left, long long right, long long a[]) {
if (dp[left][right] != -1) {
return dp[left][right];
}
if (left == right) {
return dp[left][right] = 0ll;
}
return dp[left][right] =
a[right] - a[left] +
min(quesc(left + 1, right, a), quesc(left, right - 1, a));
}
bool sortbysec(const pair<long long, long long> &a,
const pair<long long, long long> &b) {
return (a.second > b.second);
}
long long prime[1000001];
long long dp1[200007];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
long long t, n, i, j, k;
long long ans = 0;
for (i = 1; i <= 1000000; i++) prime[i] = 1;
prime[1] = 0;
for (i = 2; i * i <= 100000; i++) {
if (prime[i]) {
for (j = i * i; j <= 100000; j = j + i) {
prime[j] = 0;
}
}
}
for (i = 2; i <= 100000; i++) {
if (prime[i]) {
ans++;
}
}
factor[0] = 1;
for (i = 1; i <= 1000001; i++) {
factor[i] = (factor[i - 1] * i) % 1000000007;
}
t = 1;
cin >> t;
while (t--) {
long long x;
cin >> n >> x;
long long a[n + 1];
for (i = 1; i <= n; i++) cin >> a[i];
sort(a + 1, a + n + 1);
long long g = 0, f = 0;
for (i = 1; i <= n; i++) {
if (a[i] == x) {
g = 1;
}
if (a[i] > x / 2 && x % 2 == 0) {
f = 1;
}
if (a[i] >= x / 2 + 1 && x % 2 == 1) {
f = 1;
}
}
if (g == 1) {
cout << 1 << endl;
} else if (f == 1) {
cout << 2 << endl;
} else {
long long d = x / a[n];
if (x % a[n] != 0) {
d = d + 1;
}
cout << d << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int tc;
scanf("%lld", &tc);
while (tc--) {
long long int n, x, joss, ans = 1000000005;
scanf("%lld%lld", &n, &x);
for (long long int i = 0; i < n; i++) {
long long int a;
scanf("%lld", &a);
if (a <= x) {
joss = x / a;
if (x % a != 0) joss++;
} else
joss = 2;
ans = min(ans, joss);
}
printf("%lld\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int cmp(int a, int b) { return a > b; }
long long int a[100005];
long long int b[100005];
int main() {
map<long long int, int> mp;
int t;
scanf("%d", &t);
while (t--) {
mp.clear();
int n;
long long int x;
scanf("%d %lld", &n, &x);
for (int i = 1; i <= n; i++) {
scanf("%lld", &b[i]);
mp[b[i]] = 1;
}
sort(b + 1, b + 1 + n, cmp);
long long int ans = 2;
if (mp[x]) {
ans = 1;
} else {
ans = max(ans, (b[1] + x - 1) / b[1]);
}
printf("%lld\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 1;
const long long mod = 1e9 + 7;
template <typename T>
istream &operator>>(istream &is, vector<T> &A);
void solve() {
long long n, x;
cin >> n >> x;
vector<long long> arr(n);
cin >> arr;
sort(arr.begin(), arr.end());
long long ans = 0;
if (binary_search(arr.begin(), arr.end(), x))
ans = 1;
else
ans = max(2LL, (x + arr[n - 1] - 1) / arr[n - 1]);
cout << ans << "\n";
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
t = 1;
cin >> t;
for (int I = 1; I <= t; I++) {
solve();
}
return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &A) {
for (int i = 0; i < A.size(); i++) is >> A[i];
return is;
}
|
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double eps = 1e-8;
const int INF32 = 0x3f3f3f3f;
const long long INF64 = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const unsigned long long mod2 = 1;
const int N = 2e5 + 5;
const int sz = (1 << 20);
int a[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int q;
cin >> q;
while (q--) {
int n, x, mx = 0;
cin >> n >> x;
for (int i = 0; i < n; ++i) {
cin >> a[i];
if (a[i] == x) mx = INF32;
mx = max(mx, a[i]);
}
if (mx == INF32)
cout << 1 << '\n';
else {
int ans = x / mx;
if (x % mx) ++ans;
if (x < mx) ++ans;
cout << ans << '\n';
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long int n, d, i, j, y = 0;
cin >> n >> d;
map<long long int, long long int> a;
for (i = 0; i < n; i++) {
cin >> j;
a[j]++;
y = max(y, j);
}
if (a[d] > 0)
cout << "1\n";
else {
cout << max(2LL, (d - 1 + y) / y) << "\n";
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long int t;
cin >> t;
while (t--) solve();
cerr << "\nTime elapsed: " << setprecision(5)
<< 1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, x;
cin >> n >> x;
vector<int> arr(n);
for (int i = 0; i < n; i++) cin >> arr[i];
if (find(arr.begin(), arr.end(), x) != arr.end())
cout << 1 << endl;
else {
sort(arr.begin(), arr.end());
int max1 = arr[n - 1];
if (x % max1 == 0)
cout << max(2, x / max1) << endl;
else
cout << max(2, x / max1 + 1) << endl;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
long long t;
cin >> t;
while (t--) {
long long d, n;
cin >> n >> d;
long long a[n];
for (long long i = 0; i < n; i++) cin >> a[i];
sort(a, a + n);
long long steps, left, mini = INT_MAX;
for (long long i = n - 1; i >= 0; i--) {
steps = d / a[i];
left = d - steps * a[i];
if (left == 0) {
if (steps < mini) mini = steps;
break;
}
if (a[i] < d)
steps++;
else
steps += 2;
mini = min(steps, mini);
}
cout << mini << endl;
}
}
|
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
const int INF = 0x3f3f3f3f;
const int NINF = -INF - 1;
const double PI = acos(-1);
const int mod = 1e9 + 7;
using namespace std;
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t;
long long a;
cin >> t;
while (t--) {
long long n, x;
cin >> n >> x;
long long ans = INF, temp;
for (int i = (1); i <= (n); i++) {
cin >> a;
temp = x / a;
if (a > x) {
ans = min(ans, (long long)2);
} else if (temp * a == x)
ans = min(ans, temp);
else
ans = min(ans, temp + 1);
}
cout << ans << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long a[N];
set<long long> s;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long t;
cin >> t;
while (t--) {
long long n, x, amax = 0;
cin >> n >> x;
for (long long i = 0; i < n; i++) {
long long k;
cin >> k;
s.insert(k);
amax = max(amax, k);
}
if (s.count(x))
cout << 1 << "\n";
else {
cout << max((long long)2, (x + amax - 1) / amax) << "\n";
}
s.clear();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long n, x;
cin >> n >> x;
long long arr[n];
long long ans = 1e9;
for (int i = 0; i < n; i++) {
cin >> arr[i];
if (x % arr[i] == 0) {
ans = min(ans, x / arr[i]);
} else
ans = min(max(2LL, x / arr[i] + 1), ans);
}
cout << ans << '\n';
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
;
int t;
cin >> t;
while (t--) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
int power(int a, int b) {
if (b == 0)
return 1;
else if (b % 2 == 0)
return power((a * a) % 1000000007, b / 2);
else
return (a * power((a * a) % 1000000007, b / 2) % 1000000007);
}
int main() {
std::ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while (t--) {
int n, x, i, m, res, a;
cin >> n >> x;
set<int> s;
m = INT_MIN;
bool flag = false;
for (i = 0; i < n; i++) {
cin >> a;
s.insert(a);
m = max(m, a);
if (x == a) flag = true;
}
if (flag) {
cout << "1\n";
continue;
}
res = x / m;
if (x % m)
cout << max(2, res + 1) << '\n';
else
cout << res << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
long long t;
cin >> t;
while (t--) {
long long n, k, r = 1e18;
cin >> n >> k;
long long a[n];
for (long long i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == k) r = 1;
if (abs(k - a[i]) <= a[i]) {
long long alp = 2;
r = min(r, alp);
} else {
if (abs(a[i] - k) % a[i] == 0)
r = min(r, abs(a[i] - k) / a[i] + 1);
else
r = min(r, abs(a[i] - k) / a[i] + 2);
}
}
cout << r << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
long long n, x;
cin >> n >> x;
long long i, a[n + 1], j, w = 0;
for (i = 1; i <= n; i++) {
cin >> a[i];
if (a[i] == x) {
w = 1;
}
}
if (w == 1) {
cout << 1 << '\n';
return;
}
long long s = 0;
s = *max_element(a + 1, a + n + 1);
long long m = (x + s - 1) / s;
long long r = 2;
long long ans = max(r, m);
cout << ans << '\n';
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long t;
cin >> t;
while (t--) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
long long t;
cin >> t;
while (t--) {
long long n, x;
cin >> n >> x;
long long arr[n];
long long f = 0;
long long max = -1;
for (long long i = 0; i < n; i++) {
cin >> arr[i];
if (arr[i] == x) {
f = 1;
}
if (arr[i] > max) {
max = arr[i];
}
}
if (f == 1) {
cout << 1 << endl;
continue;
}
long long y = x / (max);
long long rest = (x % max);
long long ans = y;
if (y == 0) {
cout << 2 << endl;
continue;
}
if (rest > 0) {
ans = ans - 1 + 2;
}
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, x;
int a[N];
map<int, int> c;
int main() {
int t;
cin >> t;
while (t--) {
c.clear();
scanf("%d %d", &n, &x);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
c[a[i]] = 1;
}
sort(a, a + n);
if (c[x] != 0) {
cout << "1" << endl;
} else {
if (a[n - 1] > x) {
cout << "2" << endl;
} else {
if (x % a[n - 1] == 0)
cout << x / a[n - 1] << endl;
else
cout << x / a[n - 1] + 1 << endl;
}
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 4;
int a[N];
int main() {
int t;
cin >> t;
while (t--) {
long long n, x, val, maxi = 0;
bool ans = 0;
cin >> n >> x;
for (int i = 1; i <= n; ++i) {
cin >> val;
if (val == x) {
ans = 1;
}
maxi = max(maxi, val);
}
if (ans) {
cout << 1 << endl;
} else {
long long lo = 0, hi = 1000000000, mid;
while (lo < hi) {
mid = (lo + hi) / 2;
if (mid * maxi >= x)
hi = mid;
else
lo = mid + 1;
}
cout << max(lo, 1LL * 2) << endl;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 10;
int n, d;
int a[maxn];
map<int, bool> mp;
int main() {
ios::sync_with_stdio(false);
int _;
cin >> _;
while (_--) {
mp.clear();
cin >> n >> d;
for (int i = 1; i <= n; i++) cin >> a[i], mp[a[i]] = true;
sort(a + 1, a + 1 + n);
if (mp[d])
cout << 1 << endl;
else
cout << max(int(ceil(1.0 * d / a[n])), 2) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long min(long long a, long long b) {
if (a < b)
return a;
else
return b;
}
long long max(long long a, long long b) {
if (a > b)
return a;
else
return b;
}
int main() {
int time;
cin >> time;
for (int t = 0; t < time; t++) {
long long n, x;
cin >> n >> x;
vector<int> a(n);
long long maxi = 0;
long long answ = 1000000999999;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (x % a[i] == 0) {
answ = min(answ, x / a[i]);
}
maxi = max(a[i], maxi);
}
if (maxi > x) {
cout << min(answ, 2) << "\n";
continue;
}
long long count = x / maxi;
x -= maxi * (count);
if (x == 0) {
cout << min(count, answ) << "\n";
} else {
cout << min(count + 1, answ) << "\n";
}
}
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long double PI = acos(-1);
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;
const int mod1 = 998244353;
const long long INF = 2e18;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
int64_t n, x;
cin >> n >> x;
int64_t maxx = -MOD;
bool f = true;
for (int64_t i = 0; i < n; i++) {
int64_t k;
cin >> k;
if (k == x) {
f = false;
}
maxx = max(maxx, k);
}
int64_t temp = 0;
if (!f) {
cout << 1 << "\n";
} else {
if ((x + x % 2) / 2 > maxx) {
temp = (x - maxx) / maxx;
if ((x - temp * maxx) == maxx) {
cout << temp + 1 << "\n";
} else {
cout << temp + 2 << "\n";
}
} else {
cout << 2 << "\n";
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long nCr(long long n, long long r) {
if (r == 0 || n == r) return 1;
return nCr(n - 1, r - 1) + nCr(n - 1, r);
}
void solve() {
long long n, x;
cin >> n >> x;
long long mx = 0, flag = 0;
for (int i = 0; i < n; i++) {
long long value;
cin >> value;
if (value == x) flag = 1;
mx = max(mx, value);
}
if (flag)
cout << 1 << "\n";
else {
if (mx > x)
cout << 2 << "\n";
else
cout << (x + mx - 1) / mx << "\n";
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
;
int tt = 1;
cin >> tt;
while (tt--) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
long long n, x;
cin >> n >> x;
int a[n];
int idx = -1;
for (int i = 0; i < n; ++i) {
cin >> a[i];
if (idx == -1 || a[i] > a[idx]) {
idx = i;
}
}
int ans = x / a[idx];
int rem = x % a[idx];
int fnd = 0;
for (int i = 0; i < n; ++i) {
if (a[i] == rem) {
ans++;
fnd = 1;
break;
}
}
if (!fnd && rem != 0) {
if (ans == 0) {
ans = 2;
} else {
ans++;
}
}
cout << ans << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long bigmod(long long base, long long power, long long mod) {
if (power == 0)
return 1;
else if (power % 2 == 1) {
long long value1 = base % mod;
long long value2 = (bigmod(base, power - 1, mod)) % mod;
return (value1 * value2) % mod;
} else {
long long value1 = (bigmod(base, power / 2, mod)) % mod;
return (value1 * value1) % mod;
}
}
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n, x;
scanf("%d %d", &n, &x);
int arr[n];
bool check = false;
for (int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
if (arr[i] == x) {
check = true;
}
}
if (check)
printf("1\n");
else {
int maxi = *max_element(arr, arr + n);
double d = double(x) / double(maxi);
int hop = ceil(d);
printf("%d\n", max(2, hop));
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
class Triplet {
public:
long long x;
long long y;
long long gcd;
};
long long gcd(long long a, long long b) {
if (b == 0) return a;
return gcd(b, a % b);
}
Triplet extendedEuclid(long long a, long long b) {
if (b == 0) {
Triplet ans;
ans.gcd = a;
ans.x = 1;
ans.y = 0;
return ans;
}
Triplet smallAns = extendedEuclid(b, a % b);
Triplet ans;
ans.gcd = smallAns.gcd;
ans.x = smallAns.y;
ans.y = smallAns.x - (a / b) * smallAns.y;
return ans;
}
long long modulo(long long a, long long m) {
Triplet ans = extendedEuclid(a, m);
return ans.x;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long t;
cin >> t;
while (t--) {
long long n, a;
cin >> n >> a;
long long arr[n];
long long maxi = 0;
bool found = false;
for (long long i = 0; i < n; i++) {
cin >> arr[i];
if (found) continue;
if (a % arr[i] == 0) {
if (a / arr[i] == 1) {
found = true;
maxi = arr[i];
}
}
maxi = max(maxi, arr[i]);
}
if (found) {
cout << "1\n";
continue;
} else {
if (maxi > a) {
cout << "2\n";
continue;
} else {
long long ans = (a / maxi);
if (a % maxi != 0) ans++;
cout << ans << endl;
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int N = 1e5 + 5;
signed main() {
int t;
scanf("%d", &t);
while (t--) {
int n, x;
scanf("%d%d", &n, &x);
vector<int> a(n);
for (int i = 0; i < n; i++) scanf("%d", &a[i]);
sort(a.begin(), a.end());
if (count(a.begin(), a.end(), x)) {
cout << 1 << '\n';
continue;
}
if (a.back() > x) {
cout << 2 << '\n';
continue;
}
int ans = x / a.back();
x %= a.back();
if (!x)
cout << ans << '\n';
else
cout << ans + 1 << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, x, ras = -1, maxim = -1234567890;
cin >> n >> x;
for (int i = 1; i <= n; ++i) {
int k;
cin >> k;
if (k == x) ras = 1;
maxim = max(maxim, k);
}
if (ras != 1) {
if (x % maxim)
ras = x / maxim + 1;
else
ras = x / maxim;
ras = max(2, ras);
}
cout << ras << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cerr.tie(NULL);
long long int n, x;
long long int tc;
cin >> tc;
for (long long int t = 1; t <= tc; t++) {
cin >> n >> x;
long long int ans = INT_MAX;
vector<long long int> a(n);
long long int temp;
bool flag = false;
for (long long int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == x) flag = true;
}
sort(a.begin(), a.end());
if (a[n - 1] == x)
ans = 1;
else if (a[n - 1] > x)
ans = 2;
else {
ans = x / a[n - 1];
if (x % a[n - 1]) ans++;
}
if (flag) ans = 1;
cout << ans << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, q;
scanf("%d", &t);
for (q = 1; q <= t; q++) {
long long int n, x;
long long int k, j, ans = 9999999999999999;
cin >> n >> x;
long long int ar[n];
std::vector<long long int> v;
for (int i = 0; i < n; i++) {
cin >> ar[i];
v.push_back(ar[i]);
}
for (int i = 0; i < n; i++) {
k = x / ar[i];
if (x % ar[i] == 0)
ans = min(ans, k);
else {
if (ar[i] > x) k = 1;
ans = min(ans, k + 1);
}
}
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long n, x;
cin >> n >> x;
vector<long long> favs(n);
for (int i = 0; i < n; i++) {
int a;
cin >> a;
favs[i] = a;
}
sort(favs.begin(), favs.end());
reverse(favs.begin(), favs.end());
bool cont = true;
for (int i = 0; i < n && cont; i++) {
if (x == favs[i]) {
cont = false;
}
}
if (!cont)
cout << 1 << endl;
else if (favs[0] * 2 >= x)
cout << 2 << endl;
else {
long long ans = 0;
ans += x / favs[0];
x -= (x / favs[0]) * favs[0];
if (x == 0)
cout << ans << endl;
else
cout << ans + 1 << endl;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t = 0;
cin >> t;
int n = 0, x = 0;
for (int i = 0; i < t; ++i) {
cin >> n >> x;
int ai = 0, max = 0;
bool sb = true;
for (int i = 0; i < n; ++i) {
cin >> ai;
if (ai == x) {
sb = false;
}
if (ai > max) max = ai;
}
if (sb == false) {
cout << 1 << endl;
}
if (sb == true) {
if ((max > x) && (ai != x)) {
cout << 2 << endl;
continue;
}
if ((max != 0) && (x % max == 0)) cout << x / max << endl;
if ((max != 0) && (x % max != 0)) cout << x / max + 1 << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
long long n, x;
cin >> n >> x;
vector<long long> vec(n);
for (long long i = 0; i < n; i++) cin >> vec[i];
long long maxi = vec[0];
long long f = 0;
for (long long i = 0; i < n; i++) {
if (vec[i] == x) f = 1;
maxi = max(maxi, vec[i]);
}
if (f)
cout << "1" << endl;
else {
long long p = ceil((double)x / (double)maxi);
if (p * maxi == x)
cout << p << endl;
else {
if (p >= 2)
cout << p << endl;
else
cout << "2" << endl;
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
if (0) return;
cout << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
if (0) return;
const char* comma = strchr(names + 1, ',');
cout.write(names, comma - names) << " : " << arg1 << " | ";
__f(comma + 1, args...);
}
inline long long add(long long x, long long y) {
x += y;
if (x >= 1000000007) x -= 1000000007;
return x;
}
inline long long sub(long long x, long long y) {
x -= y;
if (x < 0) x += 1000000007;
return x;
}
inline long long mul(long long x, long long y) {
return ((x % 1000000007) * (y % 1000000007)) % 1000000007;
}
void get_it_done() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
long long gcd(long long a, long long b) {
if (a == 0) return b;
return gcd(b % a, a);
}
const long long N = 3e5 + 5;
int32_t main() {
get_it_done();
long long q = 1;
cin >> q;
while (q--) {
long long n, x;
cin >> n >> x;
vector<long long> a(n);
bool flag = 0;
for (long long i = 0; i < n; ++i) {
cin >> a[i];
if (a[i] == x) flag = 1;
}
if (flag) {
cout << 1 << "\n";
continue;
}
sort(a.begin(), a.end());
long long maxi = a[n - 1];
if (maxi > x) {
cout << 2 << "\n";
} else {
long long ans = x / maxi;
if (x % maxi != 0) {
ans += 1;
}
cout << ans << "\n";
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int qq = 1;
cin >> qq;
for (int qqq = 0; qqq < qq; qqq++) {
int n, first, v;
cin >> n >> first;
int maxx = 0;
int maxxd = 0;
for (int i = 0; i < n; i++) {
cin >> v;
maxx = max(maxx, v);
if (v <= first) {
maxxd = max(maxxd, v);
}
}
if (maxxd == 0)
cout << 2 << "\n";
else if (maxx == maxxd) {
cout << first / maxx + (first % maxx > 0) << "\n";
} else if (maxxd == first) {
cout << 1 << "\n";
} else
cout << 2 << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main(void) {
int t = 0;
cin >> t;
while (t--) {
int n = 0, x = 0, ans1 = INT_MAX;
cin >> n >> x;
for (int i = 0; i < n; ++i) {
int in1 = 0;
cin >> in1;
if (!(x % in1))
ans1 = min(ans1, x / in1);
else
ans1 = min(ans1, max(1, x / in1) + 1);
}
cout << ans1 << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
long long n, x;
cin >> n >> x;
vector<long long> a(n);
for (int i = (0); i < (n); i++) cin >> a[i];
long long mx = -1;
bool eq = false;
for (int i = (0); i < (n); i++) {
mx = max(mx, a[i]);
eq = eq || (x == a[i]);
}
if (eq)
cout << 1 << endl;
else {
long long q = x / mx;
if (x % mx) q++;
cout << max(2ll, q) << endl;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, p;
cin >> n >> p;
int ma = INT_MIN;
int f = 0;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
if (x > ma) ma = x;
if (x == p) f = 1;
}
if (f)
cout << 1 << endl;
else {
if (2 * ma >= p)
cout << 2 << endl;
else {
cout << (p - ma - 1) / ma + 2 << endl;
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long int N = 2e5 + 5;
void solve() {
long long int n, i, d;
cin >> n >> d;
long long int a[n];
for (i = 0; i < n; i++) {
cin >> a[i];
}
long long int ma = 0, ans = LLONG_MAX;
for (i = 0; i < n; i++) {
if (d < a[i]) {
ans = min((long long int)2, ans);
continue;
} else if (d == a[i]) {
cout << 1 << '\n';
return;
}
if (d % a[i] == 0) {
ans = min(d / a[i], ans);
} else {
ans = min((d / a[i]) + 1, ans);
}
}
cout << ans << '\n';
}
signed main() {
ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
long long int t = 1;
cin >> t;
while (t--) {
solve();
}
}
|
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = -1e-2;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const long long mod = 1e9 + 7;
const int Mn = INT_MIN;
const int Mx = INT_MAX;
const long long MN = LLONG_MIN;
const long long MX = LLONG_MAX;
const int N = 1e5 + 5;
void Open() {}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
Open();
int t;
cin >> t;
while (t--) {
long long n, x, mx = MN, tmp;
cin >> n >> x;
vector<long long> v(n);
int cnt = 0;
for (int i = 0; i < n; i++) {
cin >> tmp;
if (tmp == x) cnt = 1;
mx = max(mx, tmp);
}
if (cnt == 1) {
cout << 1 << "\n";
continue;
}
if (mx > x) {
cout << 2 << "\n";
continue;
} else {
cnt = (x + mx - 1) / mx;
cout << cnt << "\n";
}
}
}
|
#include <bits/stdc++.h>
int main() {
int a, b, c, d, e, f, g, h, i, t, n, x;
scanf("%d", &t);
while (t--) {
scanf("%d%d", &n, &x);
b = 0;
c = 1000000000;
while (n--) {
scanf("%d", &a);
if (x % a == 0) {
b = x / a;
} else {
if (a > x) {
b = 2;
} else {
b = x / a + 1;
}
}
if (b < c) {
c = b;
}
}
printf("%d\n", c);
}
}
|
#include <bits/stdc++.h>
using namespace std;
bool Compare(int a, int b) { return a > b; }
priority_queue<int, vector<int>, std::function<bool(int, int)>> pq(Compare);
int binary_search(vector<int> &nums, int target, int lower, int upper) {
if (lower > upper) {
return -1;
} else {
int mid = (upper + lower) / 2;
if (nums[mid] == target)
return mid;
else if (nums[mid] < target) {
return binary_search(nums, target, mid + 1, upper);
}
return binary_search(nums, target, lower, mid - 1);
}
}
int main() {
int t;
cin >> t;
for (int z = 0; z < t; z++) {
int n, x, inp;
cin >> n >> x;
int max_coin = -1;
bool equals = false;
bool greater = false;
for (int i = 0; i < n; i++) {
cin >> inp;
if (inp == x) {
equals = true;
}
if (inp > x) {
greater = true;
}
max_coin = max(max_coin, inp);
}
int div = x / max_coin;
if (equals) {
cout << 1 << '\n';
} else if (greater) {
cout << 2 << '\n';
} else if (x % max_coin == 0) {
cout << div << '\n';
} else {
cout << div + 1 << '\n';
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
const int INF = 1e9 + 10;
int T;
int n, x;
int a[MAXN], now, ans;
int main() {
cin >> T;
while (T--) {
cin >> n >> x;
now = -1, ans = INF;
for (register int i = 1; i <= n; ++i) {
cin >> a[i];
if (a[i] > x) {
ans = min(ans, 2);
continue;
}
now = max(now, a[i]);
}
if (now != -1) ans = min(ans, (int)ceil((double)x / now));
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
const long double pii = 3.141592653589793238;
long long int power(long long int x, long long int y, long long int p) {
long long int res = 1;
x = x % p;
while (y > 0) {
if (y & 1) res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
long long int max3(long long int a, long long int b, long long int c) {
return max(max(a, b), c);
}
long long int min3(long long int a, long long int b, long long int c) {
return min(min(a, b), c);
}
long long int nCr(long long int n, long long int r) {
long long int x = n - r, y = 0, z = 1;
while (y < r) {
z = (z * (x + 1)) / (y + 1);
x++;
y++;
}
return z;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long int t, i, n, d;
cin >> t;
while (t--) {
vector<long long int> v;
cin >> n >> d;
long long int a[n];
for (i = 0; i < n; i++) {
cin >> a[i];
v.push_back(a[i]);
}
sort(v.begin(), v.end());
long long int h = v[n - 1];
if (binary_search(v.begin(), v.end(), d))
cout << 1 << endl;
else {
if (d % 2 == 0) {
if (h >= d / 2)
cout << 2 << endl;
else {
if ((d - 2 * h) % h == 0)
cout << (d - 2 * h) / h + 2 << endl;
else
cout << (d - 2 * h) / h + 2 + 1 << endl;
}
} else {
if (h >= d / 2 + 1)
cout << 2 << endl;
else {
if ((d - 2 * h) % h == 0)
cout << (d - 2 * h) / h + 2 << endl;
else
cout << (d - 2 * h) / h + 2 + 1 << endl;
}
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t = 0, n = 0, x = 0, max = 0, d = 0;
cin >> t;
for (long long i = 0; i < t; i++) {
unordered_map<long long, long long> mp;
cin >> n >> x;
long long a[n];
for (long long j = 0; j < n; j++) {
cin >> a[j];
mp[a[j]] = 1;
if (a[j] > max) max = a[j];
}
if (mp[x] == 1)
cout << 1 << endl;
else {
if ((2 * max) >= x)
cout << 2 << endl;
else {
d = (x - (2 * max)) / max;
if ((x - (2 * max)) % max != 0) d++;
cout << d + 2 << endl;
}
}
d = 0;
max = 0;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int inf = 1e9;
int t, n, x, a[N], mx;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> t;
while (t--) {
cin >> n >> x;
mx = 0;
for (int i = 0; i < n; ++i) {
cin >> a[i];
mx = max(mx, a[i]);
}
int num = ceil(1.0 * x / mx);
if (num == 1) {
bool flag = 0;
for (int i = 0; i < n; ++i) {
if (a[i] == x) flag = 1;
}
if (flag)
cout << 1 << endl;
else
cout << 2 << endl;
} else
cout << num << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int t, n, x;
int a[100000];
int main() {
int i, maxa, min_cnt;
scanf("%d", &t);
for (; t > 0; t--) {
scanf("%d%d", &n, &x);
maxa = 0;
min_cnt = 0;
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
maxa = max(maxa, a[i]);
if (x == a[i]) {
min_cnt = 1;
}
}
if (min_cnt != 1) {
if (x < maxa) {
min_cnt = 2;
} else if (x > maxa) {
min_cnt = x / maxa;
if (x % maxa != 0) {
min_cnt++;
}
}
}
printf("%d\n", min_cnt);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void soln() {
int n, x;
cin >> n >> x;
int a[n + 1];
int f1 = 0, f2 = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == x) f1 = 1;
if (a[i] > x) f2 = 1;
}
if (f1 == 1) {
cout << 1 << endl;
return;
}
if (f2 == 1) {
cout << 2 << endl;
return;
}
sort(a, a + n);
int ans = x / a[n - 1];
if (x % a[n - 1]) ans += 1;
cout << ans << endl;
}
int main() {
int t;
cin >> t;
while (t--) soln();
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int n, x;
cin >> n >> x;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end(), greater<int>());
int ans = 0;
ans = (x + a[0] - 1) / a[0];
if (binary_search(a.begin(), a.end(), x, greater<int>())) {
ans = 1;
x = 0;
}
if (x && ans == 1) ans++;
cout << ans << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, d;
cin >> n >> d;
int mx = 0;
bool one = false;
for (int _ = 0; _ < n; _++) {
int x;
cin >> x;
if (x == d) {
one = true;
}
mx = max(mx, x);
}
if (one) {
cout << "1\n";
return;
} else if (mx > d) {
cout << "2\n";
return;
}
int res = (d + mx - 1) / mx;
cout << res << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int T;
cin >> T;
for (int t = 0; t < T; t++) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, x;
cin >> n >> x;
int max_ele = -1;
int flag = 0;
for (int i = 0; i < n; i++) {
int ele;
cin >> ele;
max_ele = max(max_ele, ele);
if (ele == x) flag = 1;
}
int ans;
if (x >= max_ele)
ans = ceil(((double)x) / max_ele);
else {
if (flag == 1)
ans = 1;
else
ans = 2;
}
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int c, x, y, z, m, k, l, r, i, n, t;
cin >> t;
while (t--) {
cin >> n >> m;
long long int a[n + 5], k = 0;
long long int b[n + 5];
for (i = 0; i < n; i++) {
cin >> a[i];
if (a[i] > m) {
b[k++] = 2;
} else {
if (m % a[i] == 0) {
b[k++] = m / a[i];
} else {
b[k++] = (m / a[i]) + 1;
}
}
}
sort(b, b + k);
cout << b[0] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int tt, qq;
cin >> tt;
for (qq = 1; qq <= tt; qq++) {
long long n, i, mx = 0, x, flag = 0;
cin >> n >> x;
while (n--) {
cin >> i;
mx = max(mx, i);
if (i == x) flag = 1;
}
if (flag) {
cout << 1 << endl;
} else {
cout << max((long long)2, (x + mx - 1) / mx) << endl;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f;
const long long MAXN = 1e6 + 10;
const long long mod = 1e9 + 7;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
long long t;
cin >> t;
while (t--) {
long long n, x;
long long maxx = -1;
cin >> n >> x;
long long ans = 1e10;
for (long long i = 0; i < n; i++) {
long long now;
cin >> now;
if (now > x) {
ans = min(ans, (long long)2);
} else if (x % now == 0) {
ans = min(ans, x / now);
} else {
ans = min(ans, x / now + 1);
}
}
cout << ans << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1.0);
void init() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
void infile() { freopen("output.out", "r", stdin); }
void outfile() { freopen("output.out", "w", stdout); }
long long int modex(long long int a, long long int b, long long int mod) {
if (b == 0) return 1;
if (b == 1) return a;
long long int tmp = modex(a, b / 2, mod);
tmp = (tmp * tmp) % mod;
if (b & 1) tmp = (tmp * a) % mod;
return tmp;
}
long long int arr[100005];
long long int n, x;
int main() {
init();
int tc;
cin >> tc;
while (tc--) {
cin >> n >> x;
long long int maks = -1;
int flag = 0;
for (long long int(i) = (0); (i) < (n); ++(i)) {
cin >> arr[i];
maks = max(arr[i], maks);
if (arr[i] == x) {
flag = 1;
}
}
arr[n - 1] = maks;
long long int now = 0;
if (flag) {
cout << "1\n";
} else if (arr[n - 1] * 2 >= x) {
cout << 2 << endl;
} else {
long long int ans = ceil((double)x / (double)arr[n - 1]);
cout << ans << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int t;
cin >> t;
while (t--) {
long long int n, i, j, k = -1, x, ans = 1e10, s;
cin >> n >> x;
vector<long long int> a(n), b;
map<long long int, long long int> mp;
for (i = 0; i < n; i++) {
cin >> a[i];
mp[a[i]] = 1;
k = max(k, a[i]);
}
if (mp[x] == 1)
ans = 1;
else {
if (x < k)
ans = 2;
else {
if (x % k)
ans = (x / k) + 1;
else
ans = (x / k);
}
}
cout << ans << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
static ostream& operator<<(ostream& stream, const vector<T>& t);
template <typename T>
static istream& read(T, T, istream& = cin);
template <typename T>
static istream& operator>>(istream& stream, vector<T>& t) {
return read((t).begin(), (t).end(), stream);
}
template <typename T>
static istream& read(T b, T e, istream& stream) {
for (T it = b; it != e; ++it) stream >> *it;
return stream;
}
int __() {
int n, x;
cin >> n >> x;
vector<int> a(n);
cin >> a;
sort((a).rbegin(), (a).rend());
for (int y : a)
if (y == x) return 1;
int ans = (x + a[0] - 1) / a[0];
ans = max(ans, 2);
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
int t;
cin >> t;
for (int i = 1; i <= t; ++i) {
cout << __() << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long modulo(long long num, long long MOD = 998244353) {
return ((num % MOD) + MOD) % MOD;
}
long long power(long long b, long long e, long long MOD = 998244353) {
long long ans = 1;
while (e) {
if (e % 2) ans = (ans * b) % MOD;
b = (b * b) % MOD;
e /= 2;
}
return ans;
}
long long inv(long long num, long long MOD = 998244353) {
return power(modulo(num), MOD - 2, MOD);
}
bool isp(int n) {
if (n == 0 || n == 1) return 0;
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0) return 0;
}
return 1;
}
int main() {
cout << fixed << setprecision(8);
ios_base ::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
int n, x;
cin >> n >> x;
int a[n];
int f1 = 0;
int mx = -1;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == x) f1 = 1;
mx = max(mx, a[i]);
}
if (f1)
cout << "1";
else {
int ans = (ceil((double)x / (mx)));
cout << max(2, ans);
}
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long int n, x;
cin >> n >> x;
set<long long int> s;
long long int a[n], sum;
for (int i = 0; i < n; i++) {
cin >> a[i];
s.insert(a[i]);
}
sort(a, a + n);
for (int i = n - 1; i >= 0; i--) {
if (s.find(x) != s.end()) {
sum = 1;
break;
} else {
sum = max((long long int)(2), (x + a[n - 1] - 1) / a[n - 1]);
}
}
cout << sum << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, x;
cin >> n >> x;
vector<int> arr(n, 0);
bool flag = false;
for (int i = 0; i < n; i++) {
int d;
cin >> d;
if (d == x) flag = true;
arr[i] = d;
}
if (flag)
cout << 1 << endl;
else {
sort(arr.begin(), arr.end(), greater<int>());
int ans = max(2, (int)ceil((double)x / arr[0]));
cout << ans << endl;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
int T = 1;
cin >> T;
while (T--) {
int n, x, ans = INT_MAX, f = 0;
cin >> n >> x;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
if (a[i] == x) f = 1;
ans = min(ans, x / a[i] + (x % a[i] > 0));
}
if (f)
printf("%d\n", ans);
else
printf("%d\n", max(ans, 2));
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using dl = double;
const int N = 2e5 + 10;
ll aarray[200000 + 10];
ll magic[101][101];
vector<ll> primes;
bool prime[1000001];
int main() {
ios_base::sync_with_stdio(false);
string str;
ll i, j, n, m, k, t;
cin >> t;
while (t--) {
cin >> n >> m;
set<ll> sl;
ll ma = INT_MIN;
for (i = 1; i <= n; i++) {
cin >> k;
ma = max(ma, k);
sl.insert(k);
}
if (sl.find(m) != sl.end()) {
cout << 1 << endl;
continue;
}
ll dv = m / ma;
if (m % ma) dv++;
cout << max(2LL, dv) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using bigint = int64_t;
const int MOD = 1000000007;
void io_set() {}
void solve() {
ll n, x;
cin >> n >> x;
ll a[n];
for (ll i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
ll flag = 0;
for (ll i = 0; i < n; i++) {
if (a[i] == x) {
cout << 1 << "\n";
flag = 1;
break;
}
}
if (!flag) {
for (ll i = 0; i < n; i++) {
if (a[i] >= x) {
cout << 2 << "\n";
flag = 1;
break;
}
}
}
if (!flag) {
x--;
ll ans = x / a[n - 1];
cout << ans + 1 << "\n";
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
;
io_set();
ll tt = 1;
cin >> tt;
while (tt--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
long long int n, x;
cin >> t;
while (t--) {
cin >> n >> x;
long long int a[n], flag = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (a[i] == x) flag = 1;
}
if (flag == 1)
cout << 1 << "\n";
else {
long long int *i = max_element(a, a + n);
if (((x - 1) / (*i)) + 1 < 2)
cout << 2 << "\n";
else
cout << ((x - 1) / (*i)) + 1 << "\n";
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t = 1;
cin >> t;
while (t--) {
int n, x;
cin >> n >> x;
int a[n + 10];
int f = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (a[i] == x) f = 1;
}
if (f == 1) {
cout << "1" << endl;
continue;
}
sort(a + 1, a + 1 + n);
int mn;
mn = x / a[n];
if (mn == 0) {
cout << "2" << endl;
continue;
}
if (x % a[n]) mn++;
cout << mn << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int a[100005 + 10];
char ch[100005 + 10];
int n, x;
void solve(int ii) {
scanf("%d%d", &n, &x);
int boro = 0, yes = 0;
int xx = (x + 1) / 2;
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
if (a[i] == x) yes = 1;
if (a[i] > x || xx <= a[i]) boro = 1;
}
if (yes) {
printf("1\n");
return;
}
if (boro) {
printf("2\n");
return;
}
int re = x;
sort(a, a + n);
for (int i = n - 1; i >= 0; i--) {
if (x % a[i] == 0) {
re = min(re, x / a[i]);
} else {
re = min(re, x / a[i] + 1);
}
}
printf("%d\n", re);
return;
}
int main() {
int t = 1;
scanf("%d", &t);
for (int i = 1; i <= t; i++) solve(i);
return 0;
}
|
#include <bits/stdc++.h>
int t;
using namespace std;
void solve() {
long long n, d;
cin >> n >> d;
long long ans = 999999999999;
for (int i = 1; i <= n; i++) {
long long a;
cin >> a;
if (a > d)
ans = min(ans, (long long)2);
else {
if (d % a == 0) {
ans = min(ans, d / a);
} else {
ans = min(ans, d / a + 1);
}
}
}
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(0);
cin >> t;
while (t--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
for (int TT = 0; TT < t; TT++) {
int n;
int x;
cin >> n >> x;
long long len = 0;
long long ans = 0;
for (int i = 0; i < n; i++) {
long long XX;
cin >> XX;
if (x == XX) {
ans = 1;
}
len = max(len, XX);
}
long long orgMaxLen = len;
if (ans == 0) {
if (len > x) {
ans += 2;
} else {
ans++;
}
long long h = x / orgMaxLen - 10;
if (h > 0) {
ans += h;
len += h * len;
}
while (len < x) {
len += orgMaxLen;
ans++;
}
}
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, x, ans = INT_MAX;
cin >> n >> x;
for (int i = 0; i < n; i++) {
int a, cur;
cin >> a;
cur = x / min(a, x);
if (x % a) {
cur += 1;
}
ans = min(ans, cur);
}
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAX = 105;
const long long INF = 1e9 + 7;
const long long MOD = 1e9 + 7;
const double PI = 3.1415926535;
int t, n, x, Max, temp, ans;
int main() {
scanf("%d", &t);
while (t--) {
ans = 0;
Max = 0;
scanf("%d %d", &n, &x);
for (int i = 1; i <= n; ++i) {
scanf("%d", &temp);
Max = max(Max, temp);
if (temp == x) {
ans = 1;
}
}
if (ans == 0) {
if (x % Max == 0) {
ans = max(2, x / Max);
} else {
ans = max(2, x / Max + 1);
}
}
printf("%d\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int power(int a, int b, int mod = 1e9 + 7) {
int res = 1;
while (b) {
if (b & 1) res = 1ll * res * a % mod;
a = 1ll * a * a % mod;
b >>= 1;
}
return res;
}
template <typename me>
void print(vector<me> arr) {
for (auto val : arr) cout << val << " ";
cout << endl;
}
int main() {
int t;
cin >> t;
while (t--) {
int n, X;
cin >> n >> X;
int maxi = 0;
bool done = false;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
maxi = max(x, maxi);
if (x == X) done = true;
}
if (done) {
cout << "1\n";
continue;
}
int ans;
if (maxi < X) {
ans = (X + maxi - 1) / maxi;
} else {
ans = 2;
}
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int a[100010] = {};
int n, ans, x, T;
void qs(int l, int r) {
int i = l, j = r;
int m = a[(l + r) / 2];
do {
while (a[i] < m) i++;
while (a[j] > m) j--;
if (i <= j) {
swap(a[i], a[j]);
i++;
j--;
}
} while (i <= j);
if (i < r) qs(i, r);
if (l < j) qs(l, j);
}
int main() {
cin >> T;
for (; T > 0; T--) {
cin >> n >> x;
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
qs(1, n);
if (x >= a[n]) {
ans = x / a[n];
if (x % a[n] != 0) ans++;
} else {
ans = 2;
while (a[n] > x) n--;
if (a[n] == x) ans = 1;
}
printf("%d\n", ans);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int T;
scanf("%d", &T);
while (T--) {
unsigned long long n, x;
scanf("%lld", &n), scanf("%lld", &x);
vector<unsigned long long> dat(n);
for (int i = 0; i < n; ++i) {
scanf("%lld", &dat[i]);
}
unsigned long long MIN = 1e10;
for (int i = 0; i < n; ++i) {
if (dat[i] > x) {
MIN = min(MIN, (unsigned long long)2);
} else {
MIN = min(MIN, (x + dat[i] - 1) / dat[i]);
}
}
printf("%lld\n", MIN);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int a[N];
void solve() {
int n, x;
scanf("%d%d", &n, &x);
bool flag = false;
int mx = 0;
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
mx = max(mx, a[i]);
if (a[i] == x) flag = true;
}
if (flag) {
puts("1");
} else {
if (2 * mx >= x)
puts("2");
else
printf("%d\n", x % mx == 0 ? x / mx : x / mx + 1);
}
}
int main() {
int opt;
scanf("%d", &opt);
while (opt--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
vector<int> Char[26];
void answer() {
long long n, m, ans = 0, ma = 0;
cin >> n >> m;
long long a[n + 1];
for (int i = 0; i < n; i++) {
cin >> a[i];
ma = max(ma, a[i]);
if (a[i] == m) ans = 1;
}
if (ans == 1) {
cout << 1 << "\n";
return;
} else if (ma > m) {
cout << 2 << "\n";
return;
}
if (ma < m && 2 * ma > m) {
cout << 2 << '\n';
return;
}
ans = 999999999999;
for (int i = 0; i < n; i++) {
if (m % a[i] == 0) ans = min(ans, m / a[i]);
}
int f = 2;
for (int i = 0; i < n; i++) {
if (a[i] == m % ma) f = 1;
}
ans = min(ans, (m / ma) + 1);
cout << ans << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int q;
cin >> q;
while (q--) answer();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int a[N];
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n, x;
scanf("%d%d", &n, &x);
int flag = 0x3f3f3f3f;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
if (x % a[i] == 0) {
flag = min(flag, x / a[i]);
}
}
int mx = *max_element(a + 1, a + n + 1);
if (x % mx == 0) {
printf("%d\n", min(flag, x / mx));
} else {
if (x / mx == 0) {
printf("%d\n", min(flag, 2));
} else {
printf("%d\n", min(flag, x / mx + 1));
}
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
for (const auto &x : v) os << x << " ";
return os;
}
void solve() {
int n;
ll x;
cin >> n >> x;
vector<ll> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
sort(a.begin(), a.end());
if (binary_search(a.begin(), a.end(), x)) {
cout << 1 << endl;
return;
}
ll big = a.back();
ll ans = max(2ll, (x + big - 1) / big);
cout << ans << endl;
}
int main(int argc, char const *argv[]) {
int T;
cin >> T;
for (int t = 0; t < T; t++) solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int t;
cin >> t;
for (long long int z = 0; z < t; z++) {
long long int n, x;
cin >> n >> x;
long long int arr[n + 1];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
long long int ans = 1000000000;
sort(arr, arr + n);
for (long long int i = n - 1; i >= 0; i--) {
long long int m = x / arr[i];
long long int p = x - arr[i] * m;
long long int q = m;
if (p > 0) {
q += 1;
if (q == 1) q++;
}
ans = min(ans, q);
}
cout << ans << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}
const long long MOD = 1000000007LL, INF = 1e9, LINF = 1e18;
const long double Pi = 3.141592653589793116, EPS = 1e-9;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
const long long dx[4] = {0, 1, 0, -1};
const long long dy[4] = {1, 0, -1, 0};
void solve() {
long long n, x;
cin >> n >> x;
long long ma = 0;
long long flg = 0;
for (long long i = 0; i < n; i++) {
long long s;
cin >> s;
if (s == x) {
flg = 1;
}
ma = max(ma, s);
}
if (flg) {
cout << 1 << "\n";
return;
}
long long val = ceil(x * 1.0 / ma * 1.0);
cout << max(val, (long long)2) << "\n";
return;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long t;
cin >> t;
while (t--) solve();
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.