Untitled
unknown
plain_text
2 years ago
746 B
1
Indexable
Never
#include <bits/stdc++.h> using namespace std; //codewithabby int main() { int t; cin >> t; while (t--) { int n, k; cin >> n >> k; vector<long long> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } long long left = 1, right = 1e14, ans = 0; while (left <= right) { long long mid = (left + right) / 2; long long cnt = 0; for (int i = 0; i < n; i++) { cnt += (mid / (a[i] * (i + 1))); } if (cnt >= k) { ans = mid; right = mid - 1; } else { left = mid + 1; } } cout << ans << endl; } return 0; }