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:
def numberofblues(N,A,B): 
    
    if A==0:
        return 0
    elif N<=A:
         return N
    else:
        k=N//(A+B)
        l=N-A-k*(A+B)
        if l<=B:
            return A+k*A
        else:
            return A+k*A+l-B
   
N,A,B=map(int, input().split())
print(numberofblues(N,A,B))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, blue, red = map(int, input().split())

syou = int(n/(blue+red))

plus = n - (blue+red)*syou


print(syou*blue + plus)

Submission status: Wrong Answer

Solution code:
n, blue, red = map(int, input().split())

syou = int(n/(blue+red))


plus = n - (blue+red)*syou


print(syou*blue + plus)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#B
n, a, b = [int(_) for _ in input().split()]
print((n // (a + b)) * a + n - (n // (a + b)) * (a + b))

Submission status: Wrong Answer

Solution code:
n, a, b = [int(_) for _ in input().split()]
print(n // (a + b) * a + n - n // (a + b) * (a + b))

Submission status: Wrong Answer

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

if y<=a:
  print(x*b)
else:
  print((x*b)+(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*b)+(y-a))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

if a > A:
    a = a
    
print(cnt*A + a)

Submission status: Wrong Answer

Solution code:
N,A,B=list(map(int,input().split()))
a=0
s=0
for i in range(10**18):
  a+=A
  s+=A+B
  if N<s:
    break
    print(a)

Submission status: Wrong Answer

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

print(x)

Submission status: Wrong Answer

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

print(x)

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.buffer.readline

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

div,mod =divmod(N, A+B)
print(div)
print(mod)

if div < 1:
  if N > A:
    print(A)
  else:
    print(N)
else:
  if mod > A:
    print(A*div + A)
  else:
    print(A*div + mod)

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.buffer.readline

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

div,mod =divmod(N, A+B)
print(div)
print(mod)

if div < 1:
  if N > A:
    print(A)
  else:
    print(N)
else:
  print(A*div + A)

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.buffer.readline

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

div,mod =divmod(N, A+B)

if div < 1:
  if N > A:
    print(A)
  else:
    print(N)
else:
  print(A*div + mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Set0 = List[0]//(List[1]+List[2])

Blue = Set0 * List[1] + (List[0] - (List[1]+List[2])*Set0)

print(Blue)

Submission status: Wrong Answer

Solution code:
import math

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

if a == 0:
    print(0)

elif a >= n:
    print(n)

else:
    num_a = (n // (a+b)) * a
    left_repeated = n % (a+b)
    print(num_a + left_repeated)

Submission status: Wrong Answer

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

if a >= n:
    print(n)

else:
    print(min(a, (n-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())

t = n%(a+b)

if n < (a+b):
    print(a)
else:
    if a > t > 0:
        print(n//(a+b)*a+t)
    elif t >= a:
        print(n//(a+b)*a+a)
    else:
        print(n//(a+b)*a)

Submission status: Wrong Answer

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

t = []

if n < (a+b):
    print(a)
else:
    if n % (a+b) > 0:
        print(n//(a+b)*a+a)
    else:
        print(n//(a+b)*a)

Submission status: Wrong Answer

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

t = []

if n < (a+b):
    print(a)
else:
    if n % (a+b) > 0:
        print(n//(a+b)+a)
    else: 
        print(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,a,b=map(int,input().split())
ct=a+b
num=(n/ct)*a
s=n%ct
result=num+min(s,a)
print(int(result))

Submission status: Wrong Answer

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

ans = N // (A+B) 
ama = N % (A+B) 
if(A==0):
    print(0)
elif(ama <= A):
    print(ans*A + ama)
elif(ama>A):
    print(ans+A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print (countA)

Submission status: Wrong Answer

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

a = N % (B + R)
b = N // (B + R) * B
if a >= B:
    b += a
else:
    b += a
print(b)

Submission status: Wrong Answer

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

m = N % (A + B)
count = (N // (A + B)) * A

if 0 <= m < A:
    count += m
else:
    pass

print(count)

Submission status: Wrong Answer

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

m = N % (A + B)
count = (N // (A + B)) * A

if 0 <= m <= A:
    count += m
else:
    pass

print(count)

Submission status: Wrong Answer

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

m = N % (A + B)
count = (N // (A + B)) * A

if m <= A:
    count += m
else:
    pass

print(count)

Submission status: Wrong Answer

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

m = N % (A + B)
count = (N // (A + B)) * A

if N <= A:
    count += m
else:
    pass

print(count)

Submission status: Wrong Answer

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

m = N % (A + B)
count = (N // (A + B)) * A

if N <= A:
    count += N
else:
    pass

print(count)

Submission status: Wrong Answer

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

if N <= A:
    count += N
else:
    pass

print(count)

Submission status: Wrong Answer

Solution code:
N, A, B = list(map(int, input().split()))
print('N:{}'.format(N), 'A:{}'.format(A), 'B:{}'.format(B))
#print(A*(N//(A+B)), min(A, N%(A+B)))
print(A*(N//(A+B)) + min(A, N%(A+B)))

Submission status: Wrong Answer

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

for i in range(N):
    i = i + A
    T = A
    if(i > N):
        T = T + (i-N)
    if(i <= N):
        i = i + B
    else :
        break
    
print(T)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = [int(i) for i in input().split()]
if n%(a+b)>a or n%(a+b)==0:
  print(a)
else:
  print(n%(a+b))

Submission status: Wrong Answer

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

t = []
i = 0
if n <= a+b:
    print(a)
else:
    while len(t) > n:
        t = "b"*a +"r"*b
        i += 1
    s = t[:n]
    print(s.count("b"))

Submission status: Wrong Answer

Solution code:

class abc_158:
    
    def __init__(self):
        pass
    
    def A(self):
        S=input()
        if "BA" in S or "AB" in S:print("Yes")
        else:print("No")
    
    def B(self):
        NAB=list(map(int,input().split()))
        tail = NAB[0]%(NAB[1]+NAB[2]) if NAB[0]%(NAB[1]+NAB[2])<NAB[1] else NAB[1]
        ans=((NAB[0]/(NAB[1]+NAB[2]))*NAB[1])+tail
        print(int(ans))
            
    def C(self):
        AB=list(map(int,input().split()))
        ans=-1
        
        #A<B<100
        for i in range(1,101):
            if AB[0]==int(i*0.08) and AB[1]==int(i*0.1):
                ans=i
                break
            else:continue
        print(ans)
            
    def D(self):
        pass
        
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_158()
    obj.B()

Submission status: Wrong Answer

Solution code:

N, A, B = list(map(int, input().split()))
i = 0
b = 0
r = 0

c = N//(A+B)
print(c)
d = N%(A+B)
print(d)
if d <= A:
    b = c*A + d
else:
    b = (c+1)*A
print(b)

Submission status: Wrong Answer

Solution code:

N, A, B = list(map(int, input().split()))
i = 0
b = 0
r = 0

c = N//(A+B)
#print(c)
d = N%(A+B)
#print(d)
if d <= A:
    b = c*A + d
else:
    b = c*(A+1)
print(b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

set = N // (A + B)
rest = N - set * (A + B)


if rest <= A:
    ans = A * set + rest

else:
    ans = (A+1) * set

print(ans)

Submission status: Wrong Answer

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

set = N // (A + B)
rest = N - set * (A + B)


if rest < A:
    ans = A * set + rest

else:
    ans = (A+1) * set

print(ans)

Submission status: Wrong Answer

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

resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()
n,a,b=MI()
ans=(n//(a+b))*a+n%(a+b)
print(ans)

Submission status: Wrong Answer

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

d = n // (a + b)
ans = d * a
if (n - d * (a + b) <= b):
    ans += n - d * (a + b)
else:
    ans += a

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int, input().split())
ans = 0
for _ in range(n//(a+b)): ans += a
if n % (a+b) <= a: ans += n%(a+b)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 0

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

x = n % (a+b)

if x > a:
    cnt += a
else:
    cnt += x

print(cnt)

Submission status: Wrong Answer

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

if a+b >= n:
  print(a)
elif n%(a+b) <= a:
  print((n//(a+b))*a + n%(a+b))
else:
  print((n//(a+b))*a + a)

Submission status: Wrong Answer

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

if a+b <= n:
  print(a)
elif n%(a+b) <= a:
  print((n//(a+b))*a + n%(a+b))
else:
  print((n//(a+b))*a + a)

Submission status: Wrong Answer

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

if n%(a+b)>a:
    print((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())

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

Submission status: Wrong Answer

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

x = n//(a+b)
y = n%(a+b)

print(x*a + max(y,y-b))

Submission status: Wrong Answer

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

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

print(x*a + z)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

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


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

print(int(a * A + b))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

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

print(0 if A==0 else max(A, N-B))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
c = a + b #一つの塊
d = n //c #塊が何個あるか
e = n%c #塊じゃないものが何個残るか
katamariblue = a*d
if e >=b:
    blue = b
else:
    blue = e
print(blue + katamariblue)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

ONE_BLOCK_NUM = A + B

if ONE_BLOCK_NUM != 0:
    ans += math.floor(N / ONE_BLOCK_NUM) * A # ひとかたまり丸々ある部分
    res = N % ONE_BLOCK_NUM                  # 最後の部分

    if res > 0:
        ans += res

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

ans = 0

ONE_BLOCK_NUM = A + B
ans += math.floor(N / ONE_BLOCK_NUM) * A # ひとかたまり丸々ある部分
res = N % ONE_BLOCK_NUM                  # 最後の部分

if res > 0:
    ans += res

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Kurikaeshi = N // (A + B) 
Amari = N % (A + B)
Aoi = 0 

if Amari >= B:
    Aoi = A
else:
    Aoi = Amari

result = Aoi + Kurikaeshi * A


print(result)

Submission status: Wrong Answer

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

Kurikaeshi = N // (A + B) 
Amari = N % (A + B)
Aoi = 0 

if Amari >= B:
    Aoi = B
else:
    Aoi = Amari

result = Aoi + Kurikaeshi * A


print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#  = input()
#a  = int(input())
n, a, b = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

if a == 0:
  print(0)
else:
  ans = (n // a) // 2
  if (n // (a + b)) % 2 == 1:
      ans += ans % n
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)

n,a,b = readInts()
x = math.floor(n/(a+b))
y = n-(a+b)*x
ans=a*x+min(y,b)
print(ans)

Submission status: Wrong Answer

Solution code:

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

c =0
r = n%(a+b)
if r < 1: 
    print(a)
elif r >= 1:
    t = r//(a+b)
    c += t*a
    tr = r%(a+b)
    if tr < a:
        c += tr
        print(c)
    elif tr > a:
        c += a 
        print(c)

Submission status: Wrong Answer

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


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def main():
    N, A, B = map(int, input().split())
    answer = 0
    while N > 0:
        N -= A
        answer += A
        if N > 0:
            N -= B
        else:
            print(answer+N)
            exit()
    print(answer+N)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n, a, b = map(int, input().split())

loop_count = n // (a + b)
amari = n % (a + b)
amari_a = a
if amari < a:
  amari_a = amari

print(a * loop_count + amari)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
ball = blue = 0
while ball < n:
    if ball+a < n:
        ball += a
        blue += a
    else:
        blue += n-ball
    ball += b

print(blue)

Submission status: Wrong Answer

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

NumberOfRotations = int(n/(a+b))
surplus = n%(a+b)

ans = 0

if NumberOfRotations == 0:
    if a > n:
        print(surplus)
        exit
    else:
        print(a)
        exit

ans = a*NumberOfRotations
if a > n - ((a+b)*NumberOfRotations):
    print(ans+surplus)
else:
    print(ans+a)

Submission status: Wrong Answer

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

NumberOfRotations = int(n/(a+b))
surplus = n%(a+b)

ans = 0

if NumberOfRotations == 0:
    print(a)
    exit

ans = a*NumberOfRotations
if a > n - ((a+b)*NumberOfRotations):
    print(ans+surplus)
else:
    print(ans+a)

Submission status: Wrong Answer

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

NumberOfRotations = int(n/(a+b))
surplus = n%(a+b)

ans = 0

if NumberOfRotations == 0:
    print(a)
    exit

for i in range(NumberOfRotations):
    ans += a
if a > n - ((a+b)*NumberOfRotations):
    print(ans+surplus)
else:
    print(ans+a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

list = []

while len(list) > n:
  for i in range(a):
    list.append('b')
  for j in range(b):
    list.append('a')
    
num = list.count('b')

print(num)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N, A, B = map(int, input().split())
c=A+B

if A==0:
    print(0)
else:
    d = N//c
    e = d*A
    f = N%c
    print(e+f)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N, A, B = map(int, input().split())
c=A+B

if A==0:
    print(0)
elif B==0:
    print(A)
else:
    d = N//c
    e = d*A
    f = N%c
    print(e+f)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N, A, B = map(int, input().split())
i=0
c=A+B
d=0
List=[]
while i<N:
  #print(i)
  if d<A:
    List.append("r")
  else:
    List.append("b")
  if i%c==0:
    d=0
  i+=1
  d+=1
#print(List)
print(List.count("r"))

Submission status: Wrong Answer

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

print(int(a *(n/(a+b))) + int((n%(a+b))) )

Submission status: Wrong Answer

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

for i in range(int(n/(a+b))):
    n = n - (a + b)
    count +=1

print(count*a + n)

Submission status: Wrong Answer

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

if a == 0:
  print("0")
elif b == 0:
  print(n)
else:
  ab = a + b
  sets = n // ab
  mods =  (n % ab )% a
  print(sets*a + mods)

Submission status: Wrong Answer

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

if x >= A:
    ans = A*X+4
elif x < A:
    ans = A*X+x

print(ans)

Submission status: Wrong Answer

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

if x >= A:
    ans = A*X+4
    print(ans)
elif x < A:
    ans = A*X+x
    print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,A,B=map(int,input().split())
print(int(math.floor(N/(A+B))*A+(N-(A+B)*math.floor(N/(A+B)))))

Submission status: Wrong Answer

Solution code:
import math
N,A,B=map(int,input().split())
print(math.floor(N/(A+B))*A+(N-(A+B)*math.floor(N/(A+B))))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,a,b = map(int,input().split())
count = 0
total = 0
while count < N :
    count += a 
    total += a
    if count >N :
        break
    else :
        count += b
        if count > N  :
            break
if count > N :
    total -= (count - N)       
print(total)

Submission status: Wrong Answer

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

if a==0:
    print(0)
elif n%(a+b)==0:
    print(math.floor((n/(a+b))*a))
elif n<(a+b):
    print(math.floor((a+b)/n)*a)
elif n>(a+b):
    print(a+n-(a+b))

Submission status: Wrong Answer

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

while n>=a+b:
    count+=a
    n=n-(a+b)
if a==0:
    print(0)
elif n%(a+b)==0:
    print(count)
else:
    print(count+n)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
N, A, B = map(int,input().split())
AB = A + B
n = N//AB
if A >= N:
  print(N)
  sys.exit()
if AB > N:
  print(A)
  sys.exit()
print(N-n*B)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int,input().split())
AB = A + B
n = N//AB
amari = N - n*AB
print(n*A+amari)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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,A,B = map(int,input().split())

ans = A + (N - (A + B))
if A == 0:
    print('0')

elif B == 0:
    print(N)
    
else:
    print(ans)

Submission status: Wrong Answer

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

ans = A + (N - (A + B))
if A == 0:
    print('0')
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split(" "))
ka=n//(a+b)
ja=n%(a+b)
#print(ka,ja)
if ja>a:
    bl=ka*(a+1)
    re=ka*b+ja-a
else:
    bl=ka*a+ja
    re=ka*b
print(bl)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if n%(a+b)==0:
  print(a*n//(a+b))
else:
  t=n//(a+b)
  u=n%(a+b)
  uu=min([a,u])
  print(t*a+u)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if n%(a+b)==0:
  print(b*n%(a+b))
else:
  t=n//(a+b)
  u=n%(a+b)
  uu=max([0,u-a])
  print(t*b+uu)