Program egor_sasha; var num_eg, num_sash,pri,pri1: real; var mes_eg,mes_sash: real; beginwriteln('numer egora'); readln(num_eg); writeln('numer sashi'); readln(num_sash); writeln('mesto egora (verkh=1,vniz=0)'); readln(mes_eg); writeln('mesto sashi (verkh=1,vniz=0)'); readln(mes_sash); pri: =num_sash+1; pri1: =num_eg+1; if num_eg=pri then writeln('yes') else writeln('no'); if num_sash=pri1 then writeln('yes') else writeln('no'); if mes_eg=1 then writeln('egor-high')else writeln('egor-low'); if mes_sash=1 then writeln('sasha-high')else writeln('sasha-low'); end.
#include <iostream>
typedef long long ll;
using namespace std;
bool ll_is_valid(ll t, ll N, ll x, ll y)
{
return t / x + (t - x) / y >= N;
}
ll f(ll N, ll x, ll y)
{
ll R = 1;
while (!ll_is_valid(R,N,x,y)) R *= 2;
ll L = R / 2;
while(R - L > 1)
{
ll M = (L + R) / 2;
if (!ll_is_valid(M,N,x,y)) {L = M;}
else {R = M;}
}
return R;
}
int main()
{
ll N,x,y;
cin >> N >> x >> y;
if(x > y) swap( x, y );
cout << f(N, x, y) << std::endl;
}