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: Wrong Answer

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

N = N if N <= 1000 * (A + B) else 1000 * (A + B) 

tmp1 = N // (A + B)
tmp2 = N % (A + B)
 
print(tmp1 * A + tmp2 if tmp2 < A else A)

Submission status: Wrong Answer

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

N = N if N <= 1000 else 1000

tmp1 = N // (A + B)
tmp2 = N % (A + B)
 
print(tmp1 * A + tmp2 if tmp2 < A else A)

Submission status: Wrong Answer

Solution code:
n,b,r = map(int, input().split())
if b == 0 or n == 0:
  print("0")
else:
  s = n // (b + r)
  a = n % (b + r)
  ans = s*b + a
  print("{}".format(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

tmp1 = N // (A + B)
tmp2 = N % (A + B)

print(tmp1 * A + tmp2 if tmp2 < A else A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if(a==0):
  print("0")
elif((a+b)==n):
  print(n-b)
else:
  a=a+(n-b)
  print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = [int(x) for x in input().split()]
ans = 0
kake = 0
AAA = 10 ** 18

if A + B == N:
    ans = A
elif N == 0:
    ans = 0
elif A == 0:
    ans = 0
elif B == 0:
    ans = N
elif A + B > AAA:
    ans = 0
elif N > AAA:
    ans = 0
else:
    mod = int(N % (A + B))
    kake = int(N // (A + B))
    if mod <= A:
        print(kake*A + mod)
    else:
        print(kake*A + A)

Submission status: Wrong Answer

Solution code:
N, A, B = [int(x) for x in input().split()]
ans = 0
kake = 0
AAA = 10 ** 18

if A + B == N:
    ans = A
elif N == 0:
    ans = 0
elif A == 0:
    ans = 0
elif B == 0:
    ans = N
elif A + B > AAA:
    ans = 0
elif N > AAA:
    ans = 0
else:
    kake = int(N // (A + B))
    mod = int(N % (A + B))
    if mod <= A:
        print(kake*A + mod)
    else:
        print(kake*A + A)

Submission status: Wrong Answer

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

num=n//(a+b)
ans=num*a+(n-num*(a+b))
print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
 
if a == 0:
  print(0)
elif a + b == 0:
  print(0)
else:
  q1, mod1 = divmod(n, (a + b))
  q2, mod2 = divmod(mod1, a)
  ans = (q1 + q2) * a + mod2
  print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
 
if a == 0:
  print(0)
elif a + b == 0:
  print(0)
else:
  q1, mod1 = divmod(n, (a + b))
  q2, mod2 = divmod(mod1, a)
  ans = q1 * a + q2 + mod2
  print(ans)

Submission status: Wrong Answer

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

if a == 0:
  print(0)
else:
  q1, mod1 = divmod(n, (a + b))
  q2, mod2 = divmod(mod1, a)
  ans = q1 * a + q2 + mod2
  print(ans)

Submission status: Wrong Answer

Solution code:
n, a ,b = list(map(int,(input().split())))
k = n//(a+b)
am = n%(a+b)

print(k+min(am,a))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

n, a, b = [int(val) for val in input().split()]

print(n, a, b)

ro = a + b
s = int(n / ro)
r = n % ro
ra = min(r, a)
print(s * a + ra)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if(a==0 or b==0):
  print("0")
else:
  print(min(n-a,n-b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s = list()
for i in range(5):
    for j in range(A):
        s.append("b")
    for k in range(B):
        s.append("r")
S = s[0:N]
print(S.count('b'))

Submission status: Wrong Answer

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

x = int(n/(a+b))
y = (a+b)%n
z = 0
if y <= a :
  z = y
else :
  z = a
  
print(x*a+z)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
rest = N-A-B
if N>A+B:
    answer = A + rest
    print(answer)
elif A<=N<=A+B:
    print(A)
elif A>=N:
    print(N)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,raw_input().split())
if b == 0:
  print 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = [int(x) for x in input().split()]
ans = 0
kake = 0
AAA = 10 ** 18

if A + B == N:
    ans = A
elif N == 0:
    ans = 0
elif A == 0:
    ans = 0
elif B == 0:
    ans = N
elif A + B > AAA:
    ans = 0
elif N > AAA:
    ans = 0
else:
    kake = int(N / (A + B))
    mod = int(N/(A + B))
    if mod == 0:
        ans = A * kake
    else:
        ans = A * kake + min(A, N - (N/(A-B))*(A+B))

print(ans)

Submission status: Wrong Answer

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: Wrong Answer

Solution code:

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

sum = a+b

if n < a+b:

    if n < a :
        print(n)
    else:
        print(a)

else:
    res = ((n // sum)*a) + (n % sum)
    
    if n%sum > a: 
        print(a)

    else:
        print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
rest = N-A-B
if A ==0:
    print(0)
elif N>A+B:
    answer = A + rest
    print(answer)
elif A<=N<=A+B:
    print(A)
elif A>=N:
    print(N)

Submission status: Wrong Answer

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

ans = 0

q = math.ceil(n / (a + b))


w = n - ((a + b) * (q - 1))
if w >= a:
    ans = a * q
else:
    ans = a * (q - 1) + w
    if ans < 0:
        ans = 0

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

bur = a+b
wk = n//bur
bu = wk*a
amari = n%bur

print(bu+min(b,amari))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
print(max(0,n%(a+b)-a))

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
rest = N-A-B
if A ==0:
    print(0)
elif N>A+B:
    answer = A + rest
    print(answer)
elif A<=N<=A+B:
    print(A)
elif A>N:
    print(N)

Submission status: Wrong Answer

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

if N / C < int(N / C):
    T = int(N / C) - 1
else:
    T = int(N / C)

if T == 0:
    T = 1

if N - T * C > 0:
    if A >= N - T * C:
        count = T * A + (N - T * C)
    else:
        count = T * A + A
else:
    count = T * A
if N <= A:
    count = A
if B == 0:
    count = N
print(count)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
x = 0
while(n > a):
    x += a
    n -= a
    if (n > b):
        n -= b
if(n - a > 0):
    x += n - a
else:
    x += -(a - n)
print(x)

Submission status: Wrong Answer

Solution code:
import math


def main():
    N, A, B = map(int, input().split())
    k = N // (A + B)
    g = N % (A + B)

    ans = (k * A) + A

    if A == 0:
        print(0)
    elif B == 0:
        print(N)
    elif N <= A:
        print(N)
    elif (N > A) and (N <= (A + B)):
        print(A)
    else:
        print(int(ans))

    return 0


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, A, B=list(map(int, input().split()))
if A+B==N:
	a=A
elif A==0:
    a=0
else:    
    a=N-B
  
    
print(a)

Submission status: Wrong Answer

Solution code:
import math
 
 
def main():
    N, A, B = map(int, input().split())
    k = N // (A + B)
    g = N % (A + B)
 
    ans = (k * A) + g
 
    if A == 0:
        print(0)
    elif B == 0:
        print(N)
    elif N <= A:
        print(N)
    elif N <= (A + B):
        print(A)
    else:
        print(int(ans))
 
    return 0
 
 
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if a == 0 or n == 0:
  print(0)
else:
  str_length = a + b
  if n <= str_length:
    print(a)
  else:
    count = 0
    for i in range(100):
      v = 10 ** i
      length = (v + 1) * str_length
      if length >= n:
        blue_count = (v) * a
        mod = n - v * str_length
        add = mod if mod < a else a
        count = blue_count + add
        break
    c = count if count > 0 else a * 10 ** 100
    print(count)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
rest = N-A-B
if A ==0:
    print(0)
elif N>A+B:
    answer = A + rest
    print(answer)
elif A<=N<=A+B:
    print(A)

Submission status: Wrong Answer

Solution code:
n,a,b = input().split()
N = int(n)
A = int(a)
B = int(b)
x = int(N / (A + B))
y = x * A
z = N - y
z = z - B
if N % (A + B) == 0:
    print(y)
elif A == 0:
    print(0)
else:
    print(y + z)

Submission status: Wrong Answer

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

if a == 0:
    print(0)
elif a + b >= n and n > a:
    print(a)
elif a + b >= n and n < a:
    print(n)
elif n % c == 0 and d * a:
    print(d * a)
else:
    print(a * 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
k=a//(b+c)
h=k*b
t=a-b*k-c*k
print(t+h)

Submission status: Wrong Answer

Solution code:
N, A, B = [int(x) for x in input().split()]
ans = 0
kake = 0
AAA = 10 ** 18

if A + B == N:
    ans = A
elif N == 0:
    ans = 0
elif A == 0:
    ans = 0
elif B == 0:
    ans = N
elif A + B > AAA:
    ans = 0
elif N > AAA:
    ans = 0
else:
    kake = int(N / (A + B))
    mod = int(N/(A + B))
    if mod == 0:
        ans = A * kake
    else:
        ans = A * kake + A

print(ans)

Submission status: Wrong Answer

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

count = (a+b) // n 
if count == 0:
    count = 2
con = count*(a+b)
if con - n > b:
    con -= b
    if con - n > a:
        print(a*(count-1))
    else:
        print(a*(count-1)+(a+b)*(count-1) + a -n-1)
else:
    print(a*count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if(N <= A):
    print(N)
elif(N <= A+B):
    print(A)
else:
    print(N - B*n)

Submission status: Wrong Answer

Solution code:

n, a, b = (int(x) for x in input().split())
ans = 0

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

if a != 0 :
    ans = syo * a + amari
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
NAB =input().split(' ')
N = int(NAB[0])
A = int(NAB[1])
B = int(NAB[2])
res = 0
AB = A+B
while N>A:
    res += A
    N -= AB
if N >0:
    res += N
print(N)

Submission status: Wrong Answer

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

quo = int(n/(a+b))

rem = (a+b)%n

if rem<a:
  b_all = quo*a + rem
else:
  b_all = quo*a + n
 
print(b_all)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
rest = N-A-B
if A ==0:
    print(0)
elif N>A+B:
    answer = A + rest
    print(answer)
elif A<=N<A+B:
    print(A)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if a == 0 or n == 0:
  print(0)
else:
  str_length = a + b
  if n <= str_length:
    print(a)
  else:
    count = 0
    v = 10 ** 100
    for i in range(v):
      length = (i + 1) * str_length
      if length >= n:
        blue_count = (i) * a
        mod = n - i * str_length
        add = mod if mod < a else a
        count = blue_count + add
        break
    c = count if count > 0 else a * v
    print(count)

Submission status: Wrong Answer

Solution code:
import sys
import math
N,B,R = map(int,input().split())
blue = 0
if B == 0:
  print(0)
if B != 0 and R == 0:
  print(N)
limit = N//(B+R)
blue = limit*B
difference = N - (limit * (B+R))
if difference < 0:
  print(blue)
  sys.exit(0)
if B <= difference:
  blue += B
  print(blue)
  sys.exit(0)
else:
  blue += difference
  print(blue)
  sys.exit(0)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int,input().split())
n = N -(A+B)
rb = A + B
count = 0

while n >= 0:
    if n >=0:
        count += A
        n -= rb


blue2 = N - count * rb

if blue2 > A:
    print(A+count)
else:
    print(blue2+count)

Submission status: Wrong Answer

Solution code:
import sys
n,a,b=map(int,input().split())
if a==0:
    print(0)
    sys.exit()
z=n/(a+b)
print(int(a*z)+n%(a+b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = input().split()
N = int(n)
A = int(a)
B = int(b)
x = int(N / (A + B))
y = x * A
z = N - y
z = z - B
if A == 0:
    print(0)
else:
    print(y + z)

Submission status: Wrong Answer

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

if N / C < int(N / C):
    T = int(N / C) - 1
else:
    T = int(N / C)

if T == 0:
    T = 1

if N - T * C > 0:
    if A >= N - T * C:
        count = T * A + (N - T * C)
    else:
        count = T * A + A
else:
    count = T * A

if B == 0:
    count = N
print(count)

Submission status: Wrong Answer

Solution code:
import math

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


def func():
    if A == 0 or N==0:
        return 0
    elif B==0:
        return N
    
    AB = A+B
    div = math.ceil(N/AB)
    blue = A*div
    count= AB*div
    
    if count>N:
        remain = count - N - B
        if remain > 0:
            blue = blue - remain
    return blue

print(func())

Submission status: Wrong Answer

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

else:
    print(min(n, a))

Submission status: Wrong Answer

Solution code:
N,A,B = map(int, input().split())
ab = A + B
s=0
d = 0
sa = 0
for i in range(1000000):
    s = s + ab
    d = d + A
    if s >= N:
        break
if s - B >= N:
    sa = s - N
    d = d - sa
print(d)

Submission status: Wrong Answer

Solution code:
total,blue,red=map(int,input().split())
num = -(-total)//(blue+red)
if blue == 0:
    print(0)
else:
    if (total%(red+blue)) >= blue:
        print(num*blue+(total%(red+blue)))
    else:
        print(num*blue+blue)

Submission status: Wrong Answer

Solution code:
import math

N,A,B = list(map(int,input().split()))
tama = []
kaisu = math.ceil(N /(A+ B))
amari = (A+B) * kaisu % N

if N <= A:
    print(N)
elif amari > B:
    print(abs(A* kaisu - (amari -B)))
else :
    print(A* (kaisu))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

x = 0
a = 0

while x < N - 1:
  x = x + A
  a = a + A
  x = x + B
  
while x < N:
  x = x + 1
  a = a + 1
    
print(a)

Submission status: Wrong Answer

Solution code:
import sys
import math
N,B,R = map(int,input().split())
blue = 0
if B == 0:
  print(0)
if B == 0 and R != 0:
  print(N)
limit = N//(B+R)
blue = limit*B
difference = N - (limit * (B+R))
if B <= difference:
  blue += B
  print(blue)
else:
  blue += difference
  print(blue)

Submission status: Wrong Answer

Solution code:
N, A, B=list(map(int, input().split()))
if A+B==N:
	a=A
elif A==0:
    a=A
else:    
    a=N-B
  
    
print(a)

Submission status: Wrong Answer

Solution code:

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

ans = 0

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

ans = syo * a + amari

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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


def func():
    if B == 0 or N==0:
        return 0
    elif A==0:
        return N
    
    AB = A+B
    div = math.ceil(N/AB)
    blue = A*div
    count= AB*div
    
    if count>N:
        remain = count - N - B
        if remain > 0:
            blue = blue - remain
    return blue

print(func())

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if a == 0 or n == 0:
  print(0)
else:
  str_length = a + b
  if n <= str_length:
    print(a)
  else:
    count = 0
    v = 10 ** 100
    for i in range(v):
      length = (i + 1) * str_length
      if length >= n:
        blue_count = (i) * a
        mod = n - i * str_length
        add = mod if mod < a else a
        count = blue_count + add
        break
      count = (i + 1) * a
    print(count)

Submission status: Wrong Answer

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

c = n // d
n = n % d

if n <= a:
    print(Total - c*b)
else:
    print(a * c)

Submission status: Wrong Answer

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

if A + B == N:
    ans = A
elif N == 0:
    ans = 0
elif A == 0:
    ans = 0
elif B == 0:
    ans = N
else:
    kake = int(N / (A + B))
    mod = int(N/(A + B))
    if mod == 0:
        ans = A * kake
    else:
        ans = A * kake + A

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
N,B,R = map(int,input().split())
blue = 0
if B == 0:
  print(0)
if B != 0 and R == 0:
  print(N)
limit = N//(B+R)
blue = limit*B
difference = N - (limit * (B+R))
if B <= difference:
  blue += B
  print(blue)
else:
  blue += difference
  print(blue)

Submission status: Wrong Answer

Solution code:
a, b, r = [int(x) for x in input().split()]
if b>0:
    if b + r == a:
        print(b)
    else:
        b+=1
        print(b)
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = map(int, input().split())
ab = A + B
s=0
d = 0
sa = 0
for i in range(10000000000000000000):
    s = s + ab
    d = d + A
    if s >= N:
        break
if s - B >= N:
    sa = s - N
    d = d - sa
print(d)

Submission status: Wrong Answer

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

quo = int(n/(a+b))

rem = (a+b)%n

b_all = quo*b + (rem-a)

if b_all < 0:
  print(0)
else:
  print(b_all)

Submission status: Wrong Answer

Solution code:
import sys
import math
N,B,R = map(int,input().split())
blue = 0
if B == 0:
  print(0)
if B != 0 and R == 0:
  print(N)
limit = N//(B+R) #genkai
blue = limit*B
print(blue) #15 of 100,10,7
difference = N - (limit * (B+R))
if B <= difference:
  blue += B
  print(blue)
else:
  blue += difference
  print(blue)

Submission status: Wrong Answer

Solution code:
N,B,R = input().split()
N = int(N)
B = int(B)
R = int(R)
X = B + R
Z = N // X
Y = N % X
if B == 0:
    print(0)
elif  X == N:
    print(B)
elif X < N:
    if Y < B:
        print(B*Z + Y)
    elif Y >= B:
        print(B*Z + B)
elif X > N:
    print(B)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N / C < int(N / C):
    T = int(N / C) - 1
else:
    T = int(N / C)

if T == 0:
    T = 1

if N - T * C > 0:
    if A >= N - T * C:
        count = T * A + (N - T * C)
    else:
        count = T * A + A
else:
    count = T * A

print(count)

Submission status: Wrong Answer

Solution code:
import sys
n,a,b=map(int,input().split())
if a==0:
    print(0)
    sys.exit()
z=n//(a+b)
print(a*z+n%(a+b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    
    N,A,B = map(int,input().split())
    C=A+B
    
    if C>N :
      ans=A
    else:
      K=N/C
      pp=int(K)*A
      ans=pp+(N%C)
    if A>N:
      ans=N
    print(int(ans))
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
p = list(map(int, input().split()))
n = p[0]
a = p[1]
b = p[2]

d = n % (a + b)
s = (n - d) / (a + b)

if d < a:
    ans_d = d
else:
    ans_d = a

ans = s * a + ans_d

print(int(ans))

Submission status: Wrong Answer

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

if A == 0:
    print(0)
else :
    q1, r1 = divmod(N, A+B)

    output = q1 * A

    q2, r2 = divmod(r1, A)
    
    if q2 == 1:
        output += A
    else :
        output += r2

    print(output)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

ss = s.split(" ")

N = int(ss[0])
A = int(ss[1])
B = int(ss[2])

if A == 0:
  print(0)
elif B == 0:
  print(N)
else:
  if N <= ( A + B ) :
    print(A)
  else:
    ans = 0
    div = N //( A + B ) 
    mod = N % ( A + B )
    ans = div * A

    if mod > A :
      ans += A
    else :
      ans += mod
    
    print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if a == 0 or n == 0:
  print(0)
else:
  str_length = a + b
  if n <= str_length:
    print(a)
  else:
    count = 0
    for i in range(10 ** 100):
      length = (i + 1) * str_length
      if length >= n:
        blue_count = (i) * a
        mod = n - i * str_length
        add = mod if mod < a else a
        count = blue_count + add
        break
      count = (i + 1) * a
    print(count)

Submission status: Wrong Answer

Solution code:
n, a, b = list(map(int, input().split()))
result = 0
if a + b != 0:
  roop = n // (a +b)
  extra = n - roop*(a+b)
  print(extra)
  result = a*roop
  if extra >= a:
    result += a
  else:
    result += extra
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

ss = s.split(" ")

N = int(ss[0])
A = int(ss[1])
B = int(ss[2])

if A == 0:
  print(0)
elif B == 0:
  print(N)
else:
  if N <= ( A + B ) :
    print(A)
  else:
    ans = 0
    div = N //( A + B ) # A > 0
    mod = N % ( A + B )
    ans = div * A

    if mod > A :
      ans += A
    else :
      ans += mod
    
    print(ans)

Submission status: Wrong Answer

Solution code:
total,blue,red=map(int,input().split())
num = -(-total)//(blue+red)
if blue == 0:
    print(0)
else:
    if num < 10**100:
        print(num*blue+(total%(red+blue)))
    else:
        print((10**100)*blue)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

quo = int((a+b)/n)

rem = (a+b)%n

b_all = quo*b + (rem-a)

print(b_all)

Submission status: Wrong Answer

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

ans = 0
kake = 0
if A + B == N:
    ans = A
elif A == 0:
    ans = 0
else:
    kake = int(N / (A + B))
    mod = int(N/(A + B))
    if mod == 0:
        ans = A * kake
    else:
        ans = A * kake + A

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
X = list(map(int,input().split()))

N = X[0]
b = X[1]
r = X[2]

if b == 0:
    print(0)
elif r == 0:
    print(N)
elif b + r == N:
    print(b)
else:
    b_count = 0
    Line = 0
    while Line <= N:
        Line += b
        b_count += b
        Line += r
        
    
    print(b_count)

Submission status: Wrong Answer

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

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

if(N <= A+B):
    print(A)
else:
    print(N - B*n)

Submission status: Wrong Answer

Solution code:
N,A,B = [int(x) for x in input().split()]
n = 0
blue = 0
if A == 0:
    print(0)
else:
    for i in range(10**5):
        n = n + A
        blue = blue + A
        if n >= N:
            blue = blue - (n-N)
            break
        else:
            n = n + B
            if n >= N:
                break
    print(blue)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if n<a:
    print(n)
    exit()
katamari=max(n//(a+b),1)
if n>a+b:
    amari=n%(a+b)
else:
    amari=0
print(a*katamari+amari)

Submission status: Wrong Answer

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

def main(N, A, B):

    if A == 0:
        return 0
    if B == 0:
        return N
    
    # main
    sumBlue = A * N // (A + B)

    # amari
    sumBlue += min(A, N % (A + B))

    return sumBlue

if __name__ == "__main__":

    answer = main(N, A, B)
    print(answer)

Submission status: Wrong Answer

Solution code:
import sys
n,a,b=map(int,input().split())
if a==0:
    print(0)
    sys.exit()
z=n//(a+b)
x=n%(a+b)
print(a*z+(x))

Submission status: Wrong Answer

Solution code:
n,a,b = input().split()
N = int(n)
A = int(a)
B = int(b)
x = int(N / (A + B))
y = x * A
z = N - y
if A == 0:
    print(0)
elif B == 0:
    print(0)
else:
    if z == B:
        print(y)
    else:
        y = y + z - B
        print(y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math


def main():
    N, A, B = map(int, input().split())
    k = N // (A + B)
    g = N % (A + B)

    ans = (k * A) + g

    if A == 0:
        print(0)
    elif B == 0:
        print(N)
    elif N <= A:
        print(N)
    elif N <= (A + B):
        print(A)
    else:
        print(int(ans))

    return 0


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

sum_d = 0
len_d = 0
if N >= (A+B):
    for i in range(N//(A+B)):
        sum_d = sum_d + A
        len_d = len_d + A + B
    ans = sum_d + min((N - len_d), A)
else :
    ans = A
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()

ss = s.split(" ")

N = int(ss[0])
A = int(ss[1])
B = int(ss[2])

if A == 0:
  print(0)
else:
  if N <= ( A + B ) :
    print(A)
  else:
    ans = 0
    div = N //( A + B ) # A > 0
    mod = N % ( A + B )
    ans = div * A

    if mod > A :
      ans += A
    else :
      ans += mod
    
    print(ans)