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: Time Limit Exceeded)

#include <iostream>
#include <climits>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define vb vector<bool>
#define vs vector<string>
#define px(x) cout << x << endl
#define pfi(x) printf("%d\n", x)
#define pfs(x) printf("%s\n", x)
#define sfi(x) scanf("%d", &x)
#define sfs(x) scanf("%s", x)


int main(int argc, char const *argv[])
{
    // string s;
    // cin >> s;
    // int q;
    // cin >> q;

    // int t,i;
    // char c;
    // string ss = "";
    // string es = "";

    // int rev = 0;

    // while(q--){
    //     cin >> t;
    //     if(t == 1){
    //         rev += 1;
    //         //reverse(s.begin(), s.end());
    //     }else if(t==2){
    //         cin >> i;
    //         cin >> c;
    //         if(i == 1){
    //             ss += c;
    //         }else{
    //             es += c;
    //         }
    //     }
    // }
    // //cout << ss+s+es;

    // if(rev % 2 != 0){
    //     reverse(s.begin(),s.end());
    //     reverse(ss.begin(),ss.end());
    //     reverse(es.begin(),es.end());
    // }

    // cout << es + s + ss << endl;


    // int n;
    // int p;
    // string s;
    // cin >> n >> p;
    // cin >> s;

    // int len = n;
    // int count = 0;

    // for(int i=0; i<len; i++){
    //     //int currsum = 0;
    //     for(int j=i; j<len; j++){
    //         string str = s.substr(i, j-i+1);
    //         long long ans = stol(str);
    //         if(ans % p == 0){
    //             count += 1;
    //         }
    //     }
    // }

    // cout << count  << endl;

    int n;
    cin >> n;
    int a,b;
    cin >> a >> b;
    int ta = 0;
    int tb = 0;
    int total = 0;

    while(true){
        
        if(total + a < n){
            total += a;
            ta += a;
        }else if(total + a == n){
            total += a;
            ta += a;
            break;
        }else{
            int diff = total+a-n-1;
            ta += diff;
            total = n;
            break;
        }
        //cout << ta << " ";

        if(total + b < n){
            total += b;
            tb += b;
        }else if(total + b == n){
            total += b;
            tb += b;
        }else{
            int diff = total+b-n-1;
            tb += diff;
            total = n;
            break;
        }
        if(total == n){
            break;
        }
        //cout << tb <<  " " << total<< endl;
    }
    cout << ta << endl;





    return 0;
}