Skip to content

Instantly share code, notes, and snippets.

@enzerr
Created June 23, 2023 01:01
Show Gist options
  • Save enzerr/745d9541f264df8479ad7923686866a2 to your computer and use it in GitHub Desktop.
Save enzerr/745d9541f264df8479ad7923686866a2 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 0x3f3f3f3f3f3f3f3f;
int32_t main() {
int n, m; cin >> n >> m;
int ans = INF;
int raiz = ceil(sqrt(m));
for(int i=1; i<= min(n, raiz); i++){
int x=(m+i-1)/i;
if(x<=n) ans = min(ans,i*x);
}
if(ans==INF) cout << -1 << '\n';
else cout << ans << '\n';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment