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.



Sample input:
8 3 4


Sample output:
4

Submission status: Accepted

Solution code:
N, A, B = list(map(int, input().split()))

ans = (N // (A+B)) * A

tasu = min(N % (A+B), A)
ans += tasu
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
cnt = n // (a + b)
ans = a * cnt + min((n - (a + b) * cnt), a)
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

x = N // (A + B)
y = N % (A + B)

print(x * A + min(y, A))

Submission status: Accepted

Solution code:
n,a,b = (int(x) for x in input().split())

d = n//(a+b)
c = n-d*(a+b)

if c > a:
    c=a

print(d*a+c)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

a = N // (A + B)
print(a * A + (min(N % (A+B), A)))

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
ab=a+b

x1=(n//ab)*a
x2=min(n%ab,a)
print(x1+x2)

Submission status: Accepted

Solution code:
import sys

n, a, b = [int(s) for s in sys.stdin.readline().strip().split(' ')]
ab = a + b
dividend = n // ab

ans = dividend * a + min(n % ab, a)
print(ans)

Submission status: Accepted

Solution code:
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

n,a,b = miinps()

k = a+b
ans = 0

p = n//k
q = n%k
ans +=  p*a

if q < a:
  ans += q
else:
  ans += a

print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = n//(a+b)*a+min(a, n%(a+b))
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

ans = 0
ans += (N // (A + B)) * A
ans += min(N % (A + B), A)
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def main():
    n, a, b = map(int, input().split())

    p, q = divmod(n, (a + b))

    print((p * a) + min(a, q))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, A, B = list(map(int, input().split()))
ans = N//(A+B)*A
if N%(A+B)>A:
    print(ans+A)
else:
    print(ans+N%(A+B))

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

n = N // (A+B)
r = N % (A+B)

print(n*A + min(r, A))

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
per = n // (a+b)
n -= per*(a+b)
print(per*a + min(n,a))

Submission status: Accepted

Solution code:
N, A, B = list(map(int, input().split()))

d, m = divmod(N, A + B)

ans = A * d + min(m, A)

print(ans)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())

ans=N//(A+B)
ans*=A

if N%(A+B)!=0:
    a=N%(A+B)
    if a<A:
        ans+=a
    else:
        ans+=A
print(ans)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
ans = (N//(A+B))*A + min(N%(A+B), A)
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

AB = A + B
ans = 0

ans += (N // AB) * A

if N % AB > A:
  ans += A
else:
  ans += N % AB

print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int,input().split())
ans = A*(N//(A+B)) + min(A,N%(A+B))
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, raw_input().strip().split())
q = n / (a + b)
r = n % (a + b)

ans = a * q + min(a, r)
print ans

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def solve(inp):
    (N, A, B) = map(int, inp.readline().strip().split(' '))

    a = int(N / (A + B)) * A
    r = N % (A + B)
    if r <= A:
        a += r
    else:
        a += A

    return str(a)


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys


N,A,B= map(int,input().split())

ans = N//(A+B) * A
cnt = N%(A+B)
if cnt>=A:
    ans += A
else:
    ans += cnt
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

result = 0
result += N // (A + B) * A
result += min(N % (A + B), A)
print(result)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
q, r = divmod(n, a+b)
print(q*a + min(r, a))

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())


p = n // (a + b)
q = n % (a + b)

print(p*a + min(q, a))

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

count = N // (A + B)

blue = A * count
red = B * count

N -= blue + red

if N > A:
    blue += A
    red += (N - A)
else:
    blue += N

print (blue)

Submission status: Accepted

Solution code:

N,A,B = map(int,input().split())

ans = 0

ans += N // (A+B) * A
N %= (A+B)

if N > A:
    ans += A
else:
    ans += N

print (ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())

x = n // (a+b)
d = n - x * (a+b)
a_left = min(a, d)
print(x * a + a_left)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())

k = n // (a + b)

print(k * a + min(a, n - k*(a+b)))

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ball = n // (a + b) * a
print(ball + min(n % (a + b), a))

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
print(((n//(a+b))*a)+(min((n%(a+b)),a)))

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
x=n//(a+b)
y=n%(a+b)
ans=a*x+min(y,a)
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

cnt = N // (A + B)
res = cnt * A
N -= cnt * (A + B)

if N > A:
    res += A
else:
    res += N

print(res)

Submission status: Accepted

Solution code:
import copy

import math
import fractions

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

n,a,b = ips()

ans = (n // (a+b))*a
ans+= min(n%(a+b),a)
print(ans)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
nokori = n%(a+b)
ans = a*(n//(a+b))
ans+=min(nokori,a)
print(ans)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())

ans=(n//(a+b))*a

if n%(a+b)!=0:
  q=n%(a+b)
  ans+=min(a,q)

print(ans)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split());c=a+b;print(min(a,n%c)+n//c*a)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):
    if A == 0:
        print(0)
        return
    All = A+B

    answer = (N//All)*A
    amari = N%All
    
    if amari > A:
        answer += A
    else:
        answer += amari
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

q, r = divmod(N, A + B)
print(q * A + min(r, A))

Submission status: Accepted

Solution code:
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, A, B = map(int, read().split())

mul = N // (A + B)
m = N % (A + B)

ans = A * mul + min(A, m)

print(ans)

Submission status: Accepted

Solution code:
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# 
# s = input()

N, A, B = list(map(int, input().split()))
ans = (N // (A+B)) * A + min(A, N % (A+B))
print(ans)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
print(A*(N//(A+B))+min(N%(A+B),A))

Submission status: Accepted

Solution code:
N,A,B= map(int,input().split())

n,r = divmod(N,(A+B))

ans = n * A
ans += min(r,A)
print(ans)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
x = n // (a+b)
y = min(n % (a+b),a)
print(a*x+y)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
ans = A*(N//(A+B))
ans += min(N%(A+B),A)
print(ans)

Submission status: Accepted

Solution code:
N,A,B = [int(i) for i in input().split()]
res = N // (A+B) * A
res += min(N % (A+B), A)
print(res)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
gr = n // (a+b)
amari = n % (a+b)
print(gr * a + min(amari, a))

Submission status: Accepted

Solution code:
def main():
    N, A, B = map(int, input().split())
    C = A + B
    ans = (N // C) * A
    ans += min(A, N % C)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())

cnt = 0

cnt += (N//(A+B))*A
cnt += min(A,N%(A+B))

print(cnt)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
ans=n//(a+b)*a
n%=a+b
print(ans+min(n,a))

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())

ans = n // (a+b) * a
rem = n % (a+b)
ans += min(rem, a)
print(ans)

Submission status: Accepted

Solution code:
def main():
    n, a, b = map(int, input().split())
    k = (n//(a+b))*a
    l = min(n-(n//(a+b))*(a+b), a)
    print(k+l)


main()

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
n1=n%(a+b)
n2=n//(a+b)
ans=n2*a + min(a,n1)
print(ans)

Submission status: Accepted

Solution code:
N , A, B = map(int, input().split())
ans = 0
ans += N // (A + B) * A
ans += min(N % (A + B), A)
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split()) 

print((n // (a + b)) * a + min(a, n % (a + b)))

Submission status: Accepted

Solution code:
n,a,b = [int(i) for i in input().split()]
if a > 0:
    d = n//(a+b)
    r = n-d*(a+b)
    print(d*a+min(r,a))
else:
    print(0)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
ans = N//(A+B)*A
ans += min(N%(A+B), A)
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

loop =  N // (A + B)
rest = N % (A + B)

print(loop * A + min(A, rest))

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
print(n // (a+b) * a + min(n % (a+b), a))

Submission status: Accepted

Solution code:
N,A,B = list(map(int,input().split()))

s = N//(A+B)
d = N%(A+B)

print(s*A + min(d,A))

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from bisect import bisect_left
import sys,math,itertools,pprint,fractions,time
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,a,b = inpl()
res = n//(a+b) * a
rrr = n%(a+b) 
print(res+min(rrr, a))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline

def main():
    N,A,B = map(int,input().split())
    roop = A+B
    print((N//roop)*A+min(N%roop,A))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

cnt, amari = divmod(N, (A + B))
print(cnt * A + min(amari,A))

Submission status: Accepted

Solution code:
n, a, b = [int(v) for v in input().split()]

s = a + b
print((n // s) * a + min((n % s), a))

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = (n // (a + b)) * a + min(n % (a + b), a)
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())

print(n//(a+b)*a+min(n%(a+b),a))

Submission status: Accepted

Solution code:
n,a,b = map(int, input().split())

div = n//(a+b)
rem = n%(a+b)

ans=div*a+min(rem,a)

print(ans)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
cnt = (N//(A+B))*A
N = N%(A+B)
print(cnt+min(N,A))

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
c = a+b
ans = 0
ans += a*(n//c)
if n%c > a:
    ans += a
else:
    ans += n%c
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

c = N // (A + B)

print(c * A + min(A, N - c * (A + B)))

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())

x = n // (a+b)
y = n % (a+b)
if y > a:
    y = a
print(x*a+y)

Submission status: Accepted

Solution code:
n, a, b = list(map(int, input().split()))

len_ = a + b
ans = 0
ans = (n // len_) * a

nokori = n - (n // len_) * len_
ans += min(nokori, a)
print(ans)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

i, j = divmod(N, A+B)
print(A * i + min(A, j))

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())

Q = N // (A+B)
R = N % (A+B)

if R <= A:
    print(A*Q+R)
else:
    print(A*(Q+1))

Submission status: Accepted

Solution code:
n,b,a=list(map(int, input().split()))
x=n//(a+b)
y=n%(a+b)
ct=(x*b)
if y>b: ct+=b
else: ct+=y
print(ct)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
ab = a+b
ans = 0
ans += (n // ab)*a
if n%ab >= a:
  ans += a
else:
  ans += n%ab
print(ans)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
a=0
t=N%(A+B)
a+=N//(A+B)*A
a+=min(t,A)
print(a)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
p = N//(A+B)
print(p*A+min(N%(A+B), A))

Submission status: Accepted

Solution code:
N, A, B = list(map(int, input().split()))
m = N // (A+B)
r = N % (A+B)
ans = m * A + min(r, A)
print(ans)

Submission status: Accepted

Solution code:
import sys
import math
import bisect

def solve(n, a, b):
    ans = 0
    ans += n // (a + b) * a
    m = n % (a + b)
    if m <= a:
        ans += m
    else:
        ans += a
    return ans

def main():
    n, a, b = map(int, input().split())
    ans = solve(n, a, b)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B = lr()
time, remain = divmod(N, (A+B))
answer = A * time + min(A, remain)
print(answer)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
ans = 0
tmp = N//(A+B)
ans += tmp*A
N -= (A+B)*tmp
ans += min(A,N)

print(ans)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())

kaisu=n//(a+b)
remain=n-kaisu*(a+b)
print(kaisu*a + min(a,remain))

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
if N%(A+B)<=A:
    print((N//(A+B))*A+N%(A+B))
else:
    print((N//(A+B))*A+A)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
res=n//(a+b)
print(res*a+min(n-res*(a+b),a))

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
ans = (N // (A+B)) * A + min(N % (A+B), A)
print(ans)

Submission status: Accepted

Solution code:
N,A,B = [int(i) for i in input().split()]
Loop = N//(A+B)
Amari = N%(A+B)
print(Loop*A+min(Amari,A))

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,a,b = m()

po = n // (a+b)

poo = n % (a+b)

if poo <= a:
    print(a*po + poo)
else:
    print(a*po + a)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

count = int(N // (A+B))

ans = count * A + min(A, N % (A+B))
print(ans)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
l=n//(a+b)
ans=l*a
ans+=min(n-(a+b)*l,a)
print(ans)

Submission status: Accepted

Solution code:
def main():

    N, A, B = map(int, input().split())

    m = N // (A+B)
    k = N % (A+B)
    return m * A + min(A, k)

if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
N,A,B=map(int, input().split())
print(N//(A+B)*A+min(N%(A+B),A))

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = 0
ans += (n//(a+b)) * a
ans += min(n-(n//(a+b)*(a+b)),a)
print(ans)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
k=n//(a+b)
l=n-k*(a+b)
print(k*a+min(a,l))

Submission status: Accepted

Solution code:
import sys

if __name__ == "__main__":
    N,A,B = map(int, input().split())
    ans = 0
    shou = N // (A+B)
    ans += A * shou
    amari = N % (A+B)
    ans += min(amari, A)
    print(ans)

Submission status: Accepted

Solution code:
import sys
n, a, b = [int(i) for i in sys.stdin.readline().split()]
print(n // (a + b) * a + min(n % (a + b), a))

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
ans = 0
ans += n//(a+b)*a
n = n%(a+b)
if n >= a:
  ans += a
else:
  ans += n
print(ans)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
n,a,b=map(int,input().split())
c=a+b
x=n//c
y=n-x*c
ans=a*x
ans+=min(a,y)
print(ans)

Submission status: Accepted

Solution code:
def examA():
    S = SI()
    if S=="AAA" or S=="BBB":
        print("No")
    else:
        print("Yes")
    return

def examB():
    N, A, B = LI()
    loop = N//(A+B)
    ans = loop*A + min(A,N%(A+B))
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examB()

"""

"""

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())

ret = (n // (a + b)) * a
rem = n % (a + b)
print(ret + min(rem, a))

Submission status: Accepted

Solution code:
N,A,B=list(map(int,input().split()));print(A*(N//(A+B))+min([N%(A+B),A]))

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
ans = N//(A+B)*A + min(A,N%(A+B))
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):
    C = N //(A+B)
    MOD_REMAIN = N % (A+B)
    print(C*A + min(MOD_REMAIN,A))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
d, m = divmod(n, a+b)
print(d*a + min(m, a))

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n,a,b = nm()
print((n//(a+b))*a + min(a,n%(a+b)))

Submission status: Accepted

Solution code:
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, A, B = list(map(int, sys.stdin.buffer.readline().split()))

a = N // (B + A)
b = N % (B + A)
ans = a * A
ans += min(A, b)
print(ans)

Submission status: Accepted

Solution code:
#B
N,A,B = map(int,input().split())

c = N//(A+B)
d = min(A,N%(A+B))
print(c*A+d)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
m=n//(a+b)
n-=m*(a+b)
print(m*a+min(a,n))

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
ans = n // (a+b)
n %= (a+b)
ans *= a
ans += min(a,n)
print(ans)

Submission status: Accepted

Solution code:
def main():
    N,A,B = map(int,input().split())
    ans = (N//(A+B))*A
    ans += min(A,N%(A+B))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, A, B = map(int, input().split())
if A == 0 and (B == 0):
  print(0)
  exit(0)
print((N // (A + B)) * A + min(A, N % (A + B)))

Submission status: Accepted

Solution code:
def main():
    N, A, B = map(int, input().split())

    ret = 0
    rep, rest = divmod(N, A + B)
    ret += rep * A
    ret += min(A, rest)

    print(ret)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,A,B=map(int,input().split())
    ans=0
    z=N//(A+B)
    ans+=z*A
    ans+=min(A,N-z*(A+B))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,a,b = get_nums_l()

kumi = n // (a+b)
ans = kumi*a + (min(a, n % (a+b) ))
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())

q, r = divmod(n, a + b)
ans = q * a + min(r, a)
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
r = n//(a+b)
rest = n - r * (a+b)
print(a*r + min(rest, a))

Submission status: Accepted

Solution code:
N, A, B = map(int, raw_input().split())
print N/(A+B)*A+min(N%(A+B), A)

Submission status: Accepted

Solution code:
N, A, B  = map(int, input().split())
a = N // (A + B)
b = N % (A + B)
print(a * A + min(A, b))

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
p = N//(A+B)
r = N%(A+B)
print(p*A+min(r,A))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n, a, b = [int(item) for item in input().split()]
loop = n // (a + b)
ans = loop * a + min(a, n%(a+b))
print(ans)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())

print(N//(A+B)*A + min(A,N%(A+B)))

Submission status: Accepted

Solution code:
rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())

def solve(N, A, B):
    P = A + B
    if A == 0: return 0
    Q, R = divmod(N, P)
    ans = Q * A
    if R >= A:
        ans += A
    else:
        ans += R
    return ans

print solve(*rrm())

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
m = n//(a+b)
total = n//(a+b) * a
total += min(n - m*(a+b), a)
print(total)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
x = n//(a+b)
y = n%(a+b)
print(x*a+min(y,a))

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())

div, mod = divmod(N, A + B)
ans = A * div
ans += min(mod, A)

print(ans)

Submission status: Accepted

Solution code:
N, A, B=list(map(int, input().split()))
tmp=N//(A+B)
ans=tmp*A+min(N-tmp*(A+B), A)
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
c = a+b
q, r = divmod(n, c)
ans = a*q + min(r, a)
print(ans)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
if a==0:
    print(0)
    exit()
if b==0:
    print(n)
    exit()
s=a+b
ans=(n//s)*a
m=n%s
print(ans+min(m,a))

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
c = A + B
ans = (N//c)*A
mod = N%c
ans += min(A, mod)
print(ans)

Submission status: Accepted

Solution code:
n,a,b = (int(num) for num in input().split())
print(n // (a + b) * a + min(a, n % (a + b)))

Submission status: Accepted

Solution code:
n, a, b = [int(i) for i in input().split()]
ans = n // (a + b) * a
ans += min(n % (a + b), a)
print(ans)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())

k = n // (a + b)
m = n % (a + b)

print(k * a + min(a, m))

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
s = A+B
cnt = N//s
if N%s==0:
  print(cnt*A)
else:
  x = N%s
  m = min(A, x)
  print(cnt*A+m)

Submission status: Accepted

Solution code:
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, a, b = list(map(int,ipti().split()))
    ab = a + b

    c = n // ab
    d = n % ab

    ans = c * a + min(a, d)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,a,b = map(int, input().split())
c = a+b
cnt = n//c
res = n - cnt*c

ans = a*cnt + min(res, a)
print(ans)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
tmp = a + b
ans = n // tmp * a
c = n % tmp
if c >= a:
    ans += a
else:
    ans += c
print(ans)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
q = n//(a+b)
r = n%(a+b)
print(q*a + min(a,r))

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,A,B=MI()
    ans = N//(A+B)*A
    remain = N - (N//(A+B)*(A+B))
    ans += min(remain,A)
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())

full_loop = a+b

loop = n//full_loop

rest = n-(a+b)*loop

print(loop*a+min(rest,a))

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
f = n//(a+b)
print(a*f+min(a, n%(a+b)))

Submission status: Accepted

Solution code:
N, A, B = [int(i) for i in input().split()]
S = A+B
c = (N//S)*A

c += min(N%S,A)
print(c)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
print(N//(A+B) * A + min(N%(A+B), A))

Submission status: Accepted

Solution code:
N,A,B = map(int, input().split())

t = N//(A+B)
k = N%(A+B)

if k<=A:
    pass
else:
    k = A

print(A*t + k)

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
ans = (n // (a+b)) * a
c = n % (a+b)
ans += min(c, a)
print(ans)

Submission status: Accepted

Solution code:
n,a,b = map(int, input().split())

c = n//(a+b)
d = n%(a+b)

if d > a:
    print(c*a+a)
else:
    print(c*a+d)

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
n = A+B
ans = N//n*A
ans += min(N%n, A)
print(ans)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())

ans = n // (a + b) * a + min(n % (a + b), a)
print(ans)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, a, b = na()
m = n//(a+b)
r = n%(a+b)
print(a*m+min(r, a))