Problem:
Score : 200 points

Problem Statement

Takahashi has many red balls and blue balls. Now, he will place them in a row.

Initially, there is no ball placed.

Takahashi, who is very patient, will do the following operation 10^{100} times:

Place A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.

How many blue balls will be there among the first N balls in the row of balls made this way?

Constraints

1 \leq N \leq 10^{18}

A, B \geq 0

0 < A + B \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

Print the number of blue balls that will be there among the first N balls in the row of balls.

Sample Input 1

8 3 4

Sample Output 1

4

Let b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.

Sample Input 2

8 0 4

Sample Output 2

0

He placed only red balls from the beginning.

Sample Input 3

6 2 4

Sample Output 3

2

Among bbrrrr, there are two blue balls.

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
        PEOPLE'S LIVES DON'T END WHEN THEY DIE.
        IT ENDS WHEN THEY LOSE FAITH
                                     -ITACHI UCHIHA
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
ll gcd(ll a,ll b);
ll lcm(ll a,ll b);
ll modularExponentiation(ll x,ll n,ll M);
void dsp(vector<ll> &V);
void dsp2(vector<pair<ll,ll>>&V);
void dsp3(map<ll,ll>&M);
double fact(double n);
ll nPr(ll n,ll r);
ll nCr(ll n,ll r);
ll r[40001];
ll c[40001];
void solve()
{
   ll n,a,b;cin>>n>>a>>b;
   ll cnt=0;
   cnt=(n/(a+b))*a;
   if(n%(a+b)<=a)
   cnt+=(n%(a+b));
   else
   {
       cnt+=a;
   }
   cout<<cnt<<"\n";
}
int main()
{
   fastio
    solve();
  return 0;
}
ll gcd(ll a,ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
          
} 
ll lcm(ll a,ll b)  
{  
    return (a*b)/gcd(a, b);  
}  
ll modularExponentiation(ll x,ll n,ll M)
{   
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
        result=(result * x)%M;
        x=(x*x)%M;
        n=n/2;
    }
        return result;
}
void dsp(vector<ll> &V)
{
    ull j;
    for(j=0;j<V.size();j++)
    {
        cout<<V[j]<<" ";
    }
    cout<<endl;
}
void dsp2(vector<pair<ll,ll>>&V)
{
    ull j;
    for(j=0;j<V.size();j++)
    {
        cout<<V[j].first<<" "<<V[j].second<<" ";
    }
    cout<<endl;
}
void dsp3(map<ll,ll>&M)
{
      map<ll,ll>::iterator it=M.begin();
      while(it!=M.end())
      {
        cout<<it->first<<" "<<it->second<<endl;
        it++;
      }
}
double fact(double n)
{
    double i=1;
    double res=1;
    
    if(n==0)
        return 1.00;
    
    while(i<=n)
    {
        res*=i;
        i++;
    }
    
    return res;
}
ll nPr(ll n,ll r)
{
    return (fact(n)/fact(n-r));
}
ll nCr(ll n,ll r)
{
    return (fact(n)/(fact(r)*fact(n-r)));
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>