Source Code
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define deb(x) cout << #x << " = " << x <<endl
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define endl "\n"
#define sz(u) (int)(u.size())
#define L(x)(2*x)
#define R(x)(2*x+1)
#define M(x,y)((x+y)/2)
#define int long long
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
       cout.tie(0);
    ll n,x,y;
    cin>>n>>x>>y;
    ll a1=ceil(double(n*y)/(x+y));
    ll a2=floor(double(n*y)/(x+y));
    cout<<min(max(a1*x,(n-a1)*y),max(a2*x,(n-a2)*y));
}
Copy
Hurry up tamahom
GNU G++17
0 ms
760 KB
Accepted