Source Code
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;

ll n, x, y;

int main(){
// #ifndef ONLINE_JUDGE
//   freopen("in.txt", "r", stdin);
// #endif
ios_base::sync_with_stdio(0);
cin.tie(0);

  cin >> n >> x >> y;
  int ans = 1e9;
  for(int i = 1; i <= 5e8; ++i){
    if(i % x == 0 && i % y == 0)
      if((i / x) + (i / y) == n)
        ans = min(ans, i);
  }
  cout << ans;
  
  

 
  return 0;
}
Copy
Hurry up Ammar_Lahloh
GNU G++17
1077 ms
360 KB
Time Limit Exceeded