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

using namespace std;


#define  all(a)   a.begin(), a.end()
#define  endl  '\n'
#define  ll long long
#define  set(a) fixed << setprecision(a)


int arr[1000];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    /*int t, x, y, c, b, mx, mn;
    cin >> t >> x >> y;
    mn = min(x, y);
    mx = t * mn;
    for(int i = 1; i <= t; i++)
    {
        c = x*i;
        b = y*(t-i);
        if(mx < abs(c - b))
        {

            if(max((x*(i-1)), (y*(t-i+1))) < t * x)
                cout << max((x*(i-1)), (y*(t-i+1)));
            else cout << t * x;
            break;
        }
        else mx = abs(c-b);
    }*/
    /*ll l,r,x,y,k,c=0,i,j,n=1000000007;
    cin>>l>>r>>x>>y>>k;
    i=((r*(r+1)/2)-(l*(l-1)/2));
    j=(((((r/k*((r/k)-1)/2))*k)+((r%k)*(r/k)))-((((l/k*((l/k)-1)/2)*k))+((l%k)*(l/k)))+1)%n;
    i=i*x%n;
    j=j*y%n;
    cout<<(i+j)%n;
*/

    long double x, y, c, a, v, n;
    long long t;
    cin >> t >> x >> y;
    if(x > y)
        swap(x, y);
    c = t / (x + y);
    a = floor(c * x);
    v = max(x*(t-a), y*a);
    a = ceil(c * x);
    n = max(x*(t-a), y*a);
    if(n < v)
        cout << n;
    else cout << v;
}
Copy
Hurry up tahahussein143
GNU G++17
1 ms
516 KB
Wrong Answer