Source Code
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long x,y,n,ans;
    cin >> n >> x >> y;
    if (x == 1 && y == 1) {
        cout << ceil(n/2.0) << endl;
        return 0;
    }
    if (x > y) {
        swap(x,y);
    }
    long long z =ceil(n/(double)y);
    long long w =(n-z);
    if (z*y != x*w) {
        z--;
        w++;
    }
    ans = max(z*y,x*w);
    if ((ans/x+ans/y) == n) {
        cout << ans << endl;
    }
    else {
        z++;
        w--;
        ans = max(z*y,x*w);
        cout << ans << endl;
    }
}
Copy
Hurry up MOohamed_Mahfouz
GNU G++17
0 ms
368 KB
Wrong Answer