Tim T
unknown
c_cpp
9 months ago
741 B
14
Indexable
#include <bits/stdc++.h>
#define TASK "ft"
using namespace std;
#define fst first
#define snd second
typedef long long int64;
typedef pair<int, int> pii;
const int64 oo = 1e18;
int64 div_up(int64 a, int64 b) {
return (a + b - 1)/b;
}
int main() {
#ifndef ONLINE_JUDGE
freopen(TASK".inp", "r", stdin);
freopen(TASK".out", "w", stdout);
#endif
cin.tie(0)->sync_with_stdio(false);
int64 n, m; cin >> n >> m;
if (n <= m/n && n*n < m) {
cout << "-1\n";
return 0;
}
int64 maxd = min(n, (int64)1e6);
int64 ans = oo;
for (int64 d = 1; d <= maxd; d++) {
int64 e = div_up(m, d);
if (e > n) continue;
ans = min(ans, d * e);
}
cout << ans << '\n';
}
Editor is loading...
Leave a Comment