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,b,r = map(int,input().split())
if(b == 0 and r == 0):
  print(0)
elif (b ==0):
  print(0)
else :
  sets = N/(b+r)
  surplus = N%(b+r)
  Number_of_Blue = sets * b + b
  print(Number_of_Blue)

Submission status: Wrong Answer

Solution code:
N,b,r = map(int,input().split())
if(b == 0 and r == 0):
  print(0)
else :
  sets = int(N/(b+r))
  surplus = int(N%(b+r))
  Number_of_Blue = sets * b + b
  print(Number_of_Blue)

Submission status: Wrong Answer

Solution code:
n,bl,re = map(int,input().split())
ans = 0
if bl == 0 or n < 0:
  print(round(ans))
elif bl >= n:    
  ans = ans + n
  print(round(ans))
else:
  to = bl + re
  aa = n // to
  bb = n % to
  ans = bl * aa + bb
  print(round(ans))

Submission status: Wrong Answer

Solution code:
N,b,r = map(int,input().split())
if(b==0 and r == 0):
  print(0)
else :
  sets = N/(b+r)
  surplus = N%(b+r)
  Numbe_of_Blue = sets * b + b
  print(Numbe_of_Blue)

Submission status: Wrong Answer

Solution code:
n,bl,re = map(int,input().split())
ans = 0
while n > 0:
  n = n - bl -re
  ans += bl
if bl == 0 or n < 0:
  print(round(ans))
elif bl >= n:
  ans = ans + n
  print(round(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

unit = a + b

if n > unit:
  # c: 商
  # d: 余り
  c = n // unit
  d = n % unit
  num = c * a
  if d >= a:
    num += a
  else:
    num += d
else:
  d = n % unit
  if d >= a:
    num = a
  else:
    num = d
    
print(num)

Submission status: Wrong Answer

Solution code:
N, A, B = list(map(int,input().split()))
t = []
for _ in range(A):
  t.append(0)
for _ in range(B):
  t.append(1)
  
L = len(t)

if N == L:
  print(sum(t))
elif N < L:
  for _ in range(L-N):
    del t[-1]
    print(sum(t))
elif N > L:
  Q = N // L
  R = N % L
  ANS = Q*sum(t)
  for _ in range (L-R):
    del t[-1]
  ANS = ANS + sum(t)
  print(ANS)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if a>n:
  print(a)
else:
  temp = n//(a+b)
  ans = temp*a
  temp2 = n- temp*(a+b)
  
  if temp2 < a:
    print(ans+temp2)
  else:
    print(ans+a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, b, r = map(int, input().split())
i = 1
b_count = 0
while n:
  if i%2 == 0:
    if n > b:
      b_count += b
      n = n-b
    else:
      b_count += n
      n = 0
  else:
    if n > r:
      n = n-r
    else:
      n = 0
  i += 1
print(b_count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(float,input().split())
if A==0:
  print("0")
  sys.exit()
elif B==0:
  print(int(N))
  sys.exit()
  
tmp=(int(N/(A+B))*A)
tmp_2=int(N%(A+B))
print(int(tmp+min(tmp_2,A)))

Submission status: Wrong Answer

Solution code:
list = input().split(" ")
N = int(list[0])
A = int(list[1])
B = int(list[2])

num1 = N // (A + B)
num2 = N - (A + B)
if num2 <= A:
    print(num1 * A + num2)
else:
    print(num1 * A + A)

Submission status: Wrong Answer

Solution code:
list = input().split(" ")
N = int(list[0])
A = int(list[1])
B = int(list[2])

num1 = int(N / (A + B))
num2 = N - (A + B)
if num2 <= A:
    print(num1 * A + num2)
else:
    print(num1 * A + A)

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(float,input().split())
if A==0:
  print("0")
  sys.exit()
elif B==0:
  print(int(N))
  sys.exit()
  
tmp=(int(N/(A+B))*A)
tmp_2=int(N%(A+B))
if (N%(A+B))==0:
  print(int(tmp))
else:
  print(int(tmp+tmp_2))

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(float,input().split())
if A==0:
  print("0")
  sys.exit()
elif B==0:
  print(int(N))
  sys.exit()
  
if N>=(A+B):
  tmp=(int(N/(A+B))*A)
  tmp_2=int(N%(A+B))
  if (N%(A+B))==0:
    print(int(tmp))
  else:
    print(int(tmp+tmp_2))
elif N<(A+B):
  if N>=A:
    print(int(A))
  elif N<A:
    print(int(N))

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(float,input().split())
if A==0:
  print("0")
  sys.exit()
elif B==0:
  print(int(N))
  sys.exit()

if N>=A:
  print(int(A))
  sys.exit()
elif N<A:
  print(int(N))
  sys.exit()
  
if N>=(A+B):
  tmp=(int(N/(A+B))*A)
  tmp_2=int(N%(A+B))
  if (N%(A+B))==0:
    print(int(tmp))
  else:
    print(int(tmp+tmp_2))
elif N<(A+B):
  if N>=A:
    print(int(A))
  elif N<A:
    print(int(N))

Submission status: Wrong Answer

Solution code:
n,a,b = input().split(None, 3)
N = int(n)
A = int(a)
B = int(b)
L = N // (A+B)
M = N % (A+B)
if 1 <= M <= A:
    print(A*L+M)
else:
    print(A*L)

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(float,input().split())
if A==0:
  print("0")
  sys.exit()
elif B==0:
  print(int(N))
  sys.exit()
if N>=A:
  print(int(A))
  sys.exit()
elif N<A:
  print(int(N))
  sys.exit()
  
if N>=(A+B):
  tmp=(int(N/(A+B))*A)
  tmp_2=int(N%(A+B))
  if (N%(A+B))==0:
    print(int(tmp))
  else:
    print(int(tmp+tmp_2))

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(float,input().split())
if A==0:
  print("0")
  sys.exit()
elif B==0:
  print(int(N))
  sys.exit()

if N>=(A+B):
  tmp=(int(N/(A+B))*A)
  tmp_2=int(N%(A+B))
  if (N%(A+B))==0:
    print(int(tmp))
  else:
    print(int(tmp+tmp_2))
  sys.exit()
elif N>=A:
  print(int(A))
elif N<A:
  print(int(N))

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(float,input().split())
if A==0:
  print("0")
  sys.exit()
elif B==0:
  print(int(N))
  sys.exit()

if N>=(A+B):
  tmp=(int(N/(A+B))*A)
  tmp_2=int(N%(A+B))
  if (N%(A+B))==0:
    print(int(tmp))
  else:
    print(int(tmp+tmp_2))
elif N>=A:
  print(int(A))
elif N<A:
  print(int(N))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(float,input().split())
if A==0:
  print("0")
  sys.exit()
elif B==0:
  print(int(N))
  sys.exit()

tmp=(int(N/(A+B))*A)
tmp_2=int(int((N%(A+B))))
if (N%(A+B))==0:
  print(int(tmp))
else:
  print(int(tmp+tmp_2))

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(float,input().split())
if A==0:
  print("0")
  sys.exit()
elif B==0:
  print(int(N))
  sys.exit()

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

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(float,input().split())
if A==0:
  print("0")
  sys.exit()
elif B==0:
  print(N)
  sys.exit()

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

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(float,input().split())
if A==0:
  print("0")
  sys.exit()
elif B==0:
  print(N)
  sys.exit()

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

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(float,input().split())
if A==0:
  print("0")
  sys.exit()
elif B==0:
  print(N)
  sys.exit()

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

Submission status: Wrong Answer

Solution code:
import sys
N,A,B=map(float,input().split())
if A==0:
  print("0")
  sys.exit()
elif B==0:
  print(N)
  sys.exit()

tmp=int((N/(A+B))*A)
tmp_2=int(N-(N-int((N/(A+B)))))

print(tmp+tmp_2)

Submission status: Wrong Answer

Solution code:
N,A,B=map(float,input().split())
tmp=0

while N-A-B>=0:
    tmp=tmp+A
    N=N-A-B

print(int(tmp+N))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B=[int(x) for x in input().split()]
a,b = divmod(N,A+B)
print(a*(A+1) if b>A else a*A+b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

#output
answer = 0

if N - (N//(A+B))*(A+B) <= A:
    answer += N - (N//(A+B))*B
else:
    answer += N//(A+B) + A

print(answer)

Submission status: Wrong Answer

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

#output
answer = 0

answer += N - (N//(A+B))*B

print(answer)

Submission status: Wrong Answer

Solution code:
inp = input().split()
n = int(inp[0])
a = int(inp[1])
b = int(inp[2])
ab = a + b
total = (n//ab)*a
if (n%ab < b):
    print(total+(n%ab))
else:
    print(total+b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

N, A, B = [int(x) for x in sys.stdin.readline().strip().split(" ")]

a = 0
if (A+B)*A > 0:
    a = N/(A+B)*A

b = 0
if A > 0:
    b = N%(A+B)
print(a+b)

Submission status: Wrong Answer

Solution code:
import sys

N, A, B = [int(x) for x in sys.stdin.readline().strip().split(" ")]

a = N/(A+B)*A
b = 0
if A > 0:
    b = N%(A+B)
print(a+b)

Submission status: Wrong Answer

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

n, a, b = list(map(int, input().split()))
c = a + b
x = n // c
y = n % c

ans = a * x + min(b, y)
print(ans)

Submission status: Wrong Answer

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

n, a, b = list(map(int, input().split()))
c = a + b
x = n // c
y = n % c

ans = a * x + max(0, y)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
sum_ball_num = 0
sum_blue_ball_num = 0
while True:
  if (sum_ball_num + a+b) >= n:
    if (sum_ball_num + a) >= n:
      sum_blue_ball_num += n-sum_ball_num
      break
  sum_ball_num += a+b
  sum_blue_ball_num += a
print(sum_blue_ball_num)

Submission status: Wrong Answer

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

ans = 0
if ( A + B ) > 0:
  n = N // ( A + B )
  m = N % ( A + B )
  ans = n * A + m

print(ans)

Submission status: Wrong Answer

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

ans = n // (a + b) * a
rem = n % (a + b)
ans += min(ans, rem)  # ansとremを比較することでnの位置よって処理を変えられる

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math

str = input() # input()で入力を受け取り、それを変数strに代入
print(str)
print(str.split(' '))

ary = str.split(' ')
N = int(ary[0])
B = int(ary[1])
R = int(ary[2])

if(B == 0):
  print(B)
  sys.exit()

a = N % (B+R)
ret = math.floor(N / (B+R))*B + (a if a < B else B)
print(ret)

Submission status: Wrong Answer

Solution code:
# Code for B - Count Balls
# Use input() to fetch data from STDIN
import math

[n, a, b] = map(int, input().split())
total = math.floor(n / (a + b)) * a
total += min(b, (n % (a + b)))
print(total)

Submission status: Wrong Answer

Solution code:
# Code for B - Count Balls
# Use input() to fetch data from STDIN
[n, a, b] = map(int, input().split())
total = (n // (a + b)) * a
total += min(b, (n % (a + b)))
print(total)

Submission status: Wrong Answer

Solution code:
S,A,B = map(int,input().split())
W = int(S // (A + B))
R = (S % (A + B))
if R < A:
    X = R
else:
    X = A - R


print (W * A + X)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ab = a + b
print(a * (n // ab) + (n - (n // ab) * ab))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
l = list(map(int, input().split()))
x=[]

def count1(y):
    for i in range(y):
        for j in range(l[1]):
            if len(x)<l[0]:
                x.append('b')
            else:
                return x
        for k in range(l[2]):
            if len(x)<l[0]:
                x.append('r')
            else:
                return x

count1(10*100)
print(x.count('b'))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

d, m = divmod(n, (a+b))

ans = d*a + m

print(ans)

Submission status: Wrong Answer

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

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

ad = A if A > m else m
if m == 0:
    ad = 0
answer = A * a + ad
if A == 0:
    answer = 0

print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

ad = a if a > m else m
if m == 0:
    ad = 0
answer = A * a + ad
if A == 0:
    answer = 0

print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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*int((N/(A+B))))
else:
  print(A*int((N/(A+B))))

Submission status: Wrong Answer

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


def solve(N: int, A: int, B: int):

    # if A+B < N : N = A+B
    if N <= A : print(N)
    else : 
        k = N // (A+B)
        rem = N - (A+B)*k
        b_ = A - rem
        if  b_ >= 0: print(k*A+rem+1)
        else : print(k*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: 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*int((N/(A+B))))
else:
  print(A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

C=(N-N%(A+B))/(A+B)

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

out=int(C*A+D)

print(out)

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()]
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 = 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 = map(int, input().split())
C = A + B
if N % C >= A:
  print(A*N//C+A)
else:
  print(A*N//C+N%C)

Submission status: Wrong Answer

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

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

print(r)

if r>a:
    r=a

print(q*a+r)

Submission status: Wrong Answer

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

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

if r>a:
    r=a

print(q*a+r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

N, A, B = map(int, input().split())
x = math.floor(N // (A + B))
y = N % (A + B)

print(x)

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

Submission status: Wrong Answer

Solution code:
N, b, r = list(map(int, input().split(' ')))
q, mod = divmod(N, b + r)
print(q * b + mod)

Submission status: Wrong Answer

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

if l[1] == 0:
    ans = 0
else:
    q, mod = divmod(l[0], (l[1]+l[2]))
    qq, modd = divmod(mod, l[1])
    if qq == 0 :
        ans = l[1] * q + modd
    else:
        ans = l[1] * (q + qq)

print(ans)

Submission status: Wrong Answer

Solution code:
a_list = input().split()
n = int(a_list[0])
a = int(a_list[1])
b = int(a_list[2])
#print(n)
#print(a)
#print(b)
group = int(a+b)
#print(group)
c = n%group
d = n-c
e = d/group
parta = a*e
if a>=c:
  f = c
else:
  f = a
print(int(f)+int(parta))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if a == 0:
  print('0')
else:
  base = (n//(a+b))*a
  
  n = n//(a+b)
  
  base += min(n, a)
  
  print(base)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

q=n//(a+b)
mod=n%(a+b)
if mod==0:
    print(a*q)
else:
    print(a*q+mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split(' '))
a = 0
n = 0
for _ in range(10000):
  n += (A + B)
  a += A
  if n >= N:
    break
if n - B > N:
  a -= ((n -B) - N)
print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
repeat = n // (a+b)
remain = n - (a+b) * repeat
remain_blue = max(remain - a, 0)
print(b * repeat + remain_blue)

Submission status: Wrong Answer

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

c = math.floor(n / (a + b))
if c == 0:
    d = a + b
else:
    d = n - (c * (a+b))
ans = (c*a) + min(a, d)
print(ans)

Submission status: Wrong Answer

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

c = n // (a + b)
if c == 0:
    d = a + b
else:
    d = n - (c * (a+b))
ans = (c*a) + min(a, d)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N, A, B = map(int, input().split())
period = A+B
count = math.floor(N/period)
foucs = N-count*period
if foucs>B:
  ans = A*count+A
else:
  ans = A*count+foucs
print(ans)

Submission status: Wrong Answer

Solution code:
#python3

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# 余り
surplus = n % (a + b)
# 一度に計算する部分
majority = n - surplus
# 一区切りの数
sectionCount = majority / (a + b)

blueCount = sectionCount * a

for x in range(majority, n):

    for y in range(1, a + b):
        if y <= a:
            blueCount += 1

        x += 1
        if x >= n:
            break

print("{}".format( int(blueCount) ))

Submission status: Wrong Answer

Solution code:
import math

str = input()

nums = [int(x) for x in str.split(' ')]

ct = nums[0] / (nums[1] + nums[2])
res = nums[0] % (nums[1] + nums[2])

if res > nums[1]:
  res = nums[1]

blue_ball = nums[1] * ct + res

print(math.floor(blue_ball))

Submission status: Wrong Answer

Solution code:
import math

str = input()

nums = [int(x) for x in str.split(' ')]

ct = nums[0] / (nums[1] + nums[2])
res = nums[0] % (nums[1] + nums[2])

blue_ball = nums[1] * ct + res

print(math.floor(blue_ball))

Submission status: Wrong Answer

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

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

print(div * a + mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a = str(input())
a = a.split()

a1 = int(a[0])
b1 = int(a[1])
c1 = int(a[2])

if b1 == 0:
	print(0)
else:
	ans = b1+(a1-b1-c1)
	print(ans)

Submission status: Wrong Answer

Solution code:
l=list(input().split())
N=int(l[0])
A=int(l[1])

B=int(l[2])
syou=N//(A+B)
amari=N%(A+B)
kotae=syou*A+amari
print(kotae)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a = N//(A+B)*A
b = N % (A+B)

a += min(a,b)

print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split());m=n//(a+b);print(m*b+max(0,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 ) # A > 0
    ans = div * A
    ans += min( N % (A + B) , A)
    # mod = N % ( A + B )


    # 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 b > 0:
    ope1 = n//(a+b)
    ope2 = n%(a+b)
    if ope1 == 0:
        print(n)
    elif ope2 == 0:
        print(a*ope1)
    elif ope2 < a:
        print(a*ope1 + ope2)
    else:
        print(a*ope1 + a)
else:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ope1 = n//(a+b)
ope2 = n%(a+b)

if ope1 == 0:
    print(n)
elif ope2 == 0:
    print(a*ope1)
elif ope2 < a:
    print(a*ope1 + ope2)
else:
    print(a*ope1 + a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, A, B = map(int, input().split())

# 出力
# 奇数を取得
i = 0
while (N - i * (A + B)) > 0:
    i += 1
i -= 1
tmp = i * A
if (N - tmp) > A:
    tmp2 = A
else:
    tmp2 = N - tmp

print(tmp + tmp2)

Submission status: Wrong Answer

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

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

AB = A + B

if AB == 0:
    print(0)
    sys.exit()

ans = A * N // AB
ans_mod = N % AB 

if ans_mod == 0:
    print(ans)
    sys.exit()

if ans_mod > A:
    ans += A
elif ans_mod < A:
    ans += ans_mod
elif ans_mod == A:
    ans += A
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

AB = A + B

if AB == 0:
    print(0)
    sys.exit()

ans = A * N // AB
ans_mod = N % AB 

if ans_mod == 0:
    print(ans)
    sys.exit()

if ans_mod > A:
    ans += A
elif ans_mod < A:
    ans += ans_mod

print(ans)

Submission status: Wrong Answer

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

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

AB = A + B

if AB == 0:
    print(0)
    sys.exit()

ans = A * N // AB
ans_mod = N % AB 

if ans_mod == 0:
    print(ans)
    sys.exit()

if ans_mod > A:
    ans += A
elif ans_mod <= A:
    ans += ans_mod

print(ans)

Submission status: Wrong Answer

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