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:
inp = list(map(int,input().split()))
n=inp[0]
a=inp[1]
b=inp[2]
if(a==0 and b==0):
    print (0)
else:
    k=n//(a+b)
    z=n-(a+b)*k
    if(z<=a):
        print (k*a+z)
    else:
        print ((k+1)*a)

Submission status: Accepted

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

ans = N // (A + B) * A
temp = N % (A + B)
if temp < A:
    ans += temp
else:
    ans += A
print(ans)

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
if (a[1] == 0):
    print(0)
else:
    if a[0] - int(a[0] / (a[1] + a[2])) * (a[1] + a[2]) > a[1]:
        print(int(a[0] / (a[1] + a[2])) * a[1] + a[1])
    else:
        print(int(a[0]/(a[1]+a[2]))*a[1]+a[0] -
              int(a[0] / (a[1] + a[2])) * (a[1] + a[2]))

Submission status: Accepted

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

if A != 0 and N%(A+B) <= A :
  print((N//(A+B))*A + N%(A+B))

elif A != 0 and N%(A+B) > A :
  print((N//(A+B))*A + A)

else :
  print("0")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b = map(int,input().split())
roup = n//(a+b)
ama = n%(a+b)
plus = ama if ama<a else a
print(roup*a+plus)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B = map(int,input().split())
s = int(N/(A+B))
a = N-(A+B)*s
print(int(A*s+a if A>a else A*(s+1)))

Submission status: Accepted

Solution code:
N, A, B = [int(i) for i in input().rstrip().split(' ')]
r = A + B
tmp = int(N / r) * A

print(tmp + A) if N % r >= A else print(tmp + N % r)

Submission status: Accepted

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

amari = n % (a+b) if n % (a+b)<=a else a

print(n//(a+b)*a+amari)

Submission status: Accepted

Solution code:
n,a,b = map(int, input().split())
c,d = divmod(n,a+b)
ans = c * a + min(d,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()]
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()]
answer, amari = divmod(n, a+b)
print(answer*a + min(a, amari))

Submission status: Accepted

Solution code:
n, a, b = [int(i) for i in input().split()]
answer, amari = divmod(n, a+b)
answer *= a
print(answer + min(a, amari))

Submission status: Accepted

Solution code:
n, a, b = map(int,input().split())
 
x = int(n/(a+b)) #何周目か
y = n%(a+b) #余り

if y > a:
    ans = (x+1) * a
else:
    ans = x * a + y

print(ans)

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
mul, res = n // (a + b) * a, n % (a + b)
if res <= a:
    mul += res
else:
    mul += a
print(mul)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B=(int(x) for x in input().split())
a=N//(A+B)*A
r=N%(A+B)
a+=min(r,A)
print(a)

Submission status: Accepted

Solution code:
N,A,B = map(int, input().split())
M = N/(A+B)
P = N%(A+B)
K = 0
if P != 0:
    if P > A:
        K = A
    else :
        K = P

print(A*int(M)+K)

Submission status: Accepted

Solution code:
num = input().split(' ')
data = [int(num[i]) for i in range(3)]

result = data[0] // (data[1] + data[2]) * data[1]
if(data[0] % (data[1] + data[2]) >= data[1]):
    key = data[1]
else:
    key =  data[0] % (data[1] + data[2])
result += key

print(result)

Submission status: Accepted

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

kaisu = int(n // (a+b))
amari = int(n % (a + b))
ans = kaisu * a
if amari > a:
    ans += a
else:
    ans += amari

print(ans)

Submission status: Accepted

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

sum_num = a + b
times = n // sum_num
amari = n % sum_num

ans = times * a
if amari <= a:
    ans += amari
else :
    ans += a

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L = list(map(int,input().split()))
q = L[0]//(L[1]+L[2])
mod = L[0]%(L[1]+L[2])
if mod > L[1]:
    print(q*L[1]+L[1])
elif L[1]==0:
    print(0)
else:
    print(q*L[1]+mod%L[1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = (int(x) for x in input().split())
r = N // (A + B)
ans = A * r + min((N - (A + B) * r), A)
print(ans)

Submission status: Accepted

Solution code:
x, b, r = [int(x) for x in input().split(' ')]

print((x // (b+r) * b) + min(x % (b+r),b))

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
if (A+B)==0:
  print(0)
  exit()

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

if N%(A+B)<=A:
  ans+=N%(A+B)
else:
  ans+=A

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

div, mod = divmod(n, a + b)

# print(div)
# print(mod)

count = 0
count = a * div

# print(count)

if mod >= a:
    count += a
else:
    count += mod
    
print(count)

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
num=n//(a+b)
amari=n-num*(a+b)
print(a*num+a if (amari>=a) else a*num+amari)

Submission status: Accepted

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

Submission status: Accepted

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

syou = N // (A+B)
amari = N % (A+B)

ans = syou * A 
if amari >= A:
    ans += A
else:
    ans += amari
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b=map(int,input().split())
x=n//(a+b)
if n-(a+b)*x<=a:
  t=n-x*(a+b)
else:
  t=a
print(a*x+t)

Submission status: Accepted

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

Submission status: Accepted

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

b_set = b + r

re = n % b_set

if re <= b:
    print(b * (int(n/b_set)) + re)
else:
    print(b*(int(n /b_set)+1))

Submission status: Accepted

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

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

ans = a * c

if d <= a:
    ans += d
else:
    ans += a
    
print(ans)

Submission status: Accepted

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

S=A*int(N/(A+B))
if N%(A+B)-A>0:
    S+=A
else:
    S+=N%(A+B)
print(S)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
cy = N // (A + B)
cynum = N % (A + B)
tmpans = cy * A

#print(cy)
#print(cynum)
#print(tmpans)

if 0 <= cynum and cynum < A:
    ans = cynum + tmpans
else:
    ans = tmpans + A
print(ans)

Submission status: Accepted

Solution code:
import math

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

a = math.floor(N/(A+B)) #列が何個あるか
b = N%(A+B)

if b <= A:
    print(A*a+b)
elif b>A:
    print(A*a+A)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().strip().split())
q, r = divmod(n, a+b)
blue = a*q
if r < a:
    blue += r
else:
    blue += a
print(blue)

Submission status: Accepted

Solution code:
N,A,B=[int(s) for s in input().split(" ")]
Ans1=N//(A+B)
Ans2=N%(A+B)
if Ans2>A:
    Ans3=A
else:
    Ans3=Ans2

Ans=A*Ans1+Ans3

print(int(Ans))

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
n=0
x=N//(A+B)
y=N%(A+B)-A
if y>0:
    print((x+1)*A)
else:
    print((x+1)*A+y)

Submission status: Accepted

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

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

Submission status: Accepted

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


s = n//(a+b)
t = n% (a+b)

if t>a:
    print(a*s+a)
if t<=a:
    print(a*s+t)

Submission status: Accepted

Solution code:
n,a,b = list(map(int, input().split()))
q,mod = divmod( n,(a+b) )
if mod <= a:
    print(q*a+mod)
else:
    print((q+1)*a)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
x = max(n // (a + b) - 2, 1)
while a * x + b * x < n:
    temp = a * x + b * x
    x += 1
temp = a * x + b * x
if temp - b >= n:
    temp = temp - b
    print(a * x - (temp - n))
else:
    print(a * x)

Submission status: Accepted

Solution code:
# place A blue balls first,
# then place B red balls after
# go until you get to N
n, a, b = map(int, input().split())
x = max(n // (a + b) - 2, 1)
while a * x + b * x < n:
    temp = a * x + b * x
    x += 1
temp = a * x + b * x
if temp - b >= n:
    temp = temp - b
    endsWithA = True
else:
    endsWithA = False
if endsWithA:
    print(a * x - (temp - n))
else:
    print(a * x)

Submission status: Accepted

Solution code:
import math

N, A, B = (int(x) for x in input().split())

temp = A if N % (A+B) >= A else N % (A+B)

print(math.floor(N / (A+B)) * A + temp)

Submission status: Accepted

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

Submission status: Accepted

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

c=n//(a+b)
d=n%(a+b)
e=c*a
f=c*d

if n<=a:
  print(n)
elif a<n<a+b:
  print(a)
elif a+b<=n and d<=a:
  print(e+d)
elif a+b<=n and a<=d:
  print(e+a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

if a==0:
  print(0)
else:
  s= n//(a+b)
  sn = n%(a+b)
  if sn > a:
    print (s*a+a)
  else:
    print (s*a+sn)

Submission status: Accepted

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

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())
k = n//(a+b)
r = n%(a+ b)
print(k*a+min(r,a))

Submission status: Accepted

Solution code:
N, A, B = [int(x) for x in input().split()]

n_groups = N // (A + B)
from_head = N % (A + B)

if from_head < A:
    print(n_groups * A + from_head)
else:
    print(n_groups * A + A)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""
    Author: _YL_
"""
# b:blue, r:red
n, b, r = map(int, input().split())

if b == 0:
    print("0")
elif r == 0:
    print(n)
else:
    remainder = n % (b+r)
    if remainder > b:
        remainder = b

    print(n//(b+r)*b+remainder)

Submission status: Accepted

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

m=int(n/(a+b))
r=n%(a+b)

if r>=a:
  print(a+a*m)
else:
  print(r+a*m)

Submission status: Accepted

Solution code:
from sys import stdin

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

if __name__ == "__main__":
  main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, A, B = list(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=int(N/(A+B))
ans1=int(A*X)

Y=int(N%(A+B))
ans2=0
if Y>A:
  ans2=A
elif Y==A:
  ans2=A
elif Y<A:
  ans2=Y

print(int(ans1+ans2))

Submission status: Accepted

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

Submission status: Accepted

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

c=A+B

b=0

if int(N/c)>0:
  b=(int(N/c)*A)
  if N%c>A:
    b+=A
  else:
    b+=N%c
else:
  if N<A:
    b=N
  else:
    b=A

print(b)

Submission status: Accepted

Solution code:
n, a, b = list(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())
r,p=divmod(n,a+b)
print(r*a+min([p,a]))

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
sho = N/(A+B)
ans += int(sho)*A
ans += min(N-(A+B)*int(sho),A)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ao1=a*(n//(a+b))
ao2=min(n%(a+b),a)

print(ao1+ao2)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
if A == 0:
  print(0)
elif A > N or B == 0:
  print(N)
else:
  M = N // (A + B)
  if N - M * (A + B) > A:
    print(A * M + A)
  else:
    print(N - M * B)

Submission status: Accepted

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

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

print(blue)

Submission status: Accepted

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

kakeru = n // (a+b)
amari = n % (a+b)

blue = a * kakeru + min(amari, a)

print(blue)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

if a == 0:
    print("0")
elif b == 0:
    print(n)
else:
    ans = n // (a+b)
    remainder = n % (a+b)

    if remainder > a:
        print("{}".format(ans*a + a))
    else:
        print("{}".format(ans*a + remainder))

Submission status: Accepted

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

ans = (N // S) * A
ans += min(A, N % S)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,x,y = map(int,input().split())
s = n // (x+y)
Sum = x*s
left =  n - (x+y) * s
if left > x:
    Sum += x
    
else:
    Sum += left
print(int(Sum))

Submission status: Accepted

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

if b< A:
  print(a*A+b)
if b>=A:
  print(a*A+A)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = input().split()

[n,a,b] = [int(x) for x in l]

if a==b and a==0:
    print(0)
else:
    x = a+b
    y = n//x

    if a == 0:
        print(0)
    else:
        if b == 0:
            print(n)
        else:
            t = n - y*x
            if t > a:
                print(y*a+a)
            else:
                print(y*a+t)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
# b, c =
# a = int(input())
#n = str(input())
N, A, B = [int(i) for i in input().split()]

# 判定
q = (N // (A+B)) * A
m = min((N % (A+B)),A)
print(q+m)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if y < a:
    print(x * a + y)
else:
    print(x * a + a)

Submission status: Accepted

Solution code:
a = [list(map(int, s.split())) for s in open(0)] [0]
n, r = a[0] // (a[1] + a[2]), a[0] % (a[1] + a[2])

if a[0] <= a[1] + a[2]:
    if a[0] >= a[1]:
        print(a[1])
    else:
        print(a[0])
else:
    if a[1] == 0:
        print(0)
    else:
        if r <= a[1]:
            print(n * a[1] + r)
        else:
            print(n * a[1] + a[1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


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

    if a == 0:
        print(0)
        sys.exit(0)
    if b == 0:
        ans = n
        print(ans)
        sys.exit(0)
    div = n // (a+b)
    mod = n % (a+b)
    ans = div * a
    if a >= mod:
        ans += mod
    else:
        ans += a
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

n = int(N / (A+B)) * A
m = N % (A+B)

if m > A:
    m = A
print(n + m)

Submission status: Accepted

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

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():
    import numpy as numpy
    import sys
    n,a,b=list(map(int,sys.stdin.readline().split()))
 
    print(a*(n//(a+b))+min(a,n%(a+b)))
 
 
 
main()

Submission status: Accepted

Solution code:
from math import floor

inp = input()
N, A, B = [int(x) for x in inp.split(" ")]

steps = floor(N / (A + B))
cap = steps * (A + B)
blue_balls = steps * A + min([N - cap, A])
print(blue_balls)

Submission status: Accepted

Solution code:
# 初期入力
N,A,B = map(int, input().split(" "))

# 青A個と赤Bを並べると、A+Bの組み合わせが何個あるか
kanz = N//(A+B) *A

# 余りを考える
saigo = min(N%(A+B),A)
print(kanz + saigo)

Submission status: Accepted

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

import sys


def prob_b(n, a, b):
    x = int(n / (a + b)) * a
    y = min(n % (a + b), a)
    print(x+y)


if __name__ == '__main__':
    #args = sys.argv
    #n = args[1]
    #a = args[2]
    #b = args[3]
    n, a, b = map(int, input().split())
    prob_b(n,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:
    print(x*A+y)
else:
    print(x*A+A)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
total_balls, blue, red = [int(i) for i in input().split()]

balls_per_loop = red + blue
loops = total_balls // balls_per_loop
ex = total_balls % balls_per_loop

ex_blue = blue if ex >= blue else ex
total_blue = blue * loops + ex_blue
print(total_blue)

Submission status: Accepted

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

Submission status: Accepted

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

ans = ans + min(rem,a)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
ab = A + B
x = N // ab
y = N % ab

if y >= A:
  print((x + 1) * A)
else:
  print(x * A + y)

Submission status: Accepted

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

tmp1,tmp2=divmod(n,a+b)

blue=tmp1*a
if(tmp2>a):
  blue=blue+a
else:
  blue=blue+tmp2
  
print(blue)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
def count_balls(n, a, b):
    if(a==0): return 0
    if(n<a): return n
    end = n % (a+b)
    if(end > a):
        return a*(n//(a+b))+a
    else:
        return a*(n//(a+b))+end
n,a,b=map(int, input().strip().split())
print(count_balls(n,a,b))

Submission status: Accepted

Solution code:
inputs = input().split(' ')
n = int(inputs[0])
a = int(inputs[1])
b = int(inputs[2])
sum = a + b

if n <= a:
    print(n)
elif n <= sum:
    print(a)
else:
    loop = n // sum
    num = n - loop * sum
    if num <= a:
        print(loop * a + num)
    else:
        print(loop * a + a)

Submission status: Accepted

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

q = int(N / (A+B))
r = N%(A+B)
#print((q+1)*A if r>A else q*A+r)
print(q*A + min(A, r))

Submission status: Accepted

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

q = int(N / (A+B))
r = N%(A+B)
print((q+1)*A if r>A else q*A+r)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
num=N//(A+B)
res=N-num*(A+B)
count=0
if res<=A:
  count=num*A+res
else:
  count=num*A+A
print(count)

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())
if a+b == 0:
  x = 0
else:
	s = n//(a+b)
	t = n%(a+b)
	if t <= a:
		x = s*a+t
	else:
		x = s*a+a
print(x)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

if(n % (a+b) > a):
    ans += a
else:
    ans += n%(a+b)

print(ans)

Submission status: Accepted

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

perid = n//(a+b)
rest = n%(a+b)

print(a*perid + (rest if rest < a else a))

Submission status: Accepted

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

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

print(ans * a + res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
data = input().split()
n = int(data[0])
a = int(data[1])
b = int(data[2])

div = n // (a + b)
amari = n % (a + b)
if amari > a:
  amari = a

res = div * a + amari

print(res)

Submission status: Accepted

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

repeats = N//(A+B)
amari = N%(A+B)
if amari >= A:
    amari = A
else: 
    amari = amari
print(repeats*A + amari)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, b, r = map(int, input().split())
if n - (b+r)*(n //(b+r)) <= b:
    print((n //(b+r))*b + n - (b+r)*(n //(b+r)))
else:
    print((n //(b+r))*b + b)

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
t = a + b
count = t if t > 0 else 0
r = 0
if count == 0:
	r = 0
else:
	d = int(n/t)
	if d*t == n:
		r = d * a
	else:
		r = d * a
		e = n - d*t
		if e <= a:
			r = r + e
		else:
			r = r + a
print(r)

Submission status: Accepted

Solution code:
# 入力の取得
i = list(map(int, input().split()))
kazoeru = i[0]
ao = i[1]
aka= i[2]
kaisuu = i[0]/(i[1]+i[2])

answer = divmod(kazoeru, (i[1]+i[2]))

if ao == 0:
    print(0)
    exit()

#商の分を計算
aa = ao * answer[0]

#あまりの分を計算
if answer[1] == 0:
    print(aa)
    exit()

#あまり6で、青が6なら
# あまりが青より多いなら(あまり4、青2)
if answer[1] >= ao:
    aa += ao
#あまりが青より少ないなら(あまり1、青3)
else:
    aa += answer[1]
print(aa)

Submission status: Accepted

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

Submission status: Accepted

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

T = N//(A+B)
U = N%(A+B)

print(T*A + min(U,A))

Submission status: Accepted

Solution code:
n,a,b = map(int, input().split())
if a == 0:
	print(0)
elif 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 = (int(x) for x in input().split())
c = N // (A+B)
d = N % (A+B)
if d >= A:
    print((c+1)*A)
else:
    print(c*A+d)

Submission status: Accepted

Solution code:
def cal(N,A,B):
    C=int(N/(A+B))
    W=N%(A+B)
    if W > A:
        return C*A+A
    else:
        return C*A+W

    

if __name__ == "__main__":
    N,A,B = input().split()
    N=int(N)
    A=int(A)
    B=int(B)
    cal(N,A,B)
    print(cal(N,A,B))

Submission status: Accepted

Solution code:
N, A, B = list(map(int, input().split()))
x = N // (A + B)
y = N % (A + B)

if y < A:
    print(x * A + y)
else:
    print(x * A + A)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
o=input().split()
n=int(o[0])
a=int(o[1])
b=int(o[2])

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

if n%(a+b)>=a:
    ans+=a
else:
    ans+=n%(a+b)

print(str(ans)+'\n')

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
oneRound = a + b
roundCnt = n // oneRound
mod = n % oneRound

ans = roundCnt * a + min(mod, a)
print(ans)

Submission status: Accepted

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

ans = (n//c)*a
l = n%c
if a>l:
  ans += l
else:
  ans += a
  
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


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

main()

Submission status: Accepted

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

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

if a>=q:
  answer=(a*r)+q
else:
  answer=a*(r+1)
  
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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