-
-
Save enzerr/745d9541f264df8479ad7923686866a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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