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:
# Author: cr4zjh0bp
# Created: Sat Mar  7 12:01:50 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

from math import ceil

N, A, B = na()
C = N % (A + B)
if C == N:
    print(A)
else:
    print(A * (N // (A + B)) + C)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if A==0 and B==0:
    print("0")
    exit(0)

AB = A+B
if N <= AB*(10**100):
    print ((N-(N//AB)*AB) + ((N//AB)*A))
else:
    print (A*(10**100))

Submission status: Wrong Answer

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

a = int(B+R)
b = int(N/a)
c = int(N%a)

if b <= 0:
    if R ==0:
        print(N)
    else:
        if B > N:
            print(N)
        else:
            print(B)
else:
    if R == 0:
        print(N)
    else:
        print((b*B)+c)

Submission status: Wrong Answer

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

if A > 0 & B >= 0:
    number = int(N / (A + B))
    r = int(N % (A + B))
    print(A*number + r)
if A == 0:
    print(0)

Submission status: Wrong Answer

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

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

# 青色(0)の色が0個の時は、すぐに終了させる。
if a == 0:
    print("0")
    exit()

# まず、割り算ですぐに出せる青色の数を出す
bluecount1 = a * (n // (a + b))

if (n % (a+b)) == 0:
    seq = (a+b)
else:
    seq = n % (a+b)

if n > (a+b):
    if seq <= a:
        bluecount2 = seq
    else:
        bluecount2 = a
else:
    bluecount2 = 0

ans = bluecount1 + bluecount2
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

if n<=a:
    ans=n
elif n<=(a+b): 
    ans=math.ceil(n/(a+b))*a
else:
    ans=int(n/(a+b))*a + n%(a+b)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

to = int(n / (a + b))
ans = to * a
ans += n - ((a + b) * to)

print(ans)

Submission status: Wrong Answer

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

if a == 0:
    print("0")
if b == 0:
    print(int(n))
else:
   tmp = int(n) - int(b)
   print(tmp)

Submission status: Wrong Answer

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

x = ''
y = ''
z = ''
for i in range(a):
  x = x + '0'

for i in range(b):
  y = y + '1'
  
for i in range(10*100):
  z = z + x + y

print(z[:n].count('0'))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

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  X == N:
    print(B)
elif X < N:
    if Y < B:
        print(B*Z + Y)
    elif Y > B:
        print(B*Z + Y-B)

Submission status: Wrong Answer

Solution code:
from math import floor
i = list(map(int, input().split()))
n, a, b = i
print(floor(n / (a+b))*a + n % (a+b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# B - Count Balls
n, a, b = map((int),(input().split()))


if a == 0:
    print(0)
else:
    count = (int)(n / (a + b))
    amari = (int)(n % (a + b))

    print(count * a + amari)

Submission status: Wrong Answer

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

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

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

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

zentai_num = N // (A+B)
zentai_b = zentai_num * A


amari_num = N % (A+B)

amari_b = 0
if amari_num >= B:
    amari_b = B
else:
    amari_b = amari_num

# amari_b = max(amari_num - B,0)

# print(amari_num,amari_b)

print(zentai_b + amari_b)

Submission status: Wrong Answer

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

x,y = divmod(n,a+b)
ans = y
if a == 0:
    ans = 0
elif a > y:
    ans += x*a
else:
    ans = x*(a+1)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

to = int(n / (a + b))
ans = to * a
ans += n - ((a + b) * to)

print(ans)

Submission status: Wrong Answer

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

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

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:
N, A, B = map(int, input().split())
count = N // (A+B)
result = N - (B*count)

if N % (A+B) != 0:
    nokori = N - result
    if nokori - A >= 0:
        result += nokori
    else:
        result += A

print(result)

Submission status: Wrong Answer

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

a = N // (A+B)

if a > 1:
  ans = A*a + A
else:
  ans = A + (N-(A+B))

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

ans = 0

if N < A:
  print("0")
  sys.exit()

if N < A+B:
  print(N-A)
  sys.exit()

print((int)(B*(N/(A+B))) + (N%(A+B)-A))

Submission status: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
d=0
e=0
ok=False

total=int(a/(b+c))
sa=a-(b+c)*total
if total==0:
    print(b)
else:
    if sa>=b:
        print(b+b*total)
    else:
        print(sa+b*total)

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())

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

if (rest >= A):
    result = A*num_move
else:
    result = A*(num_move-1)+rest

print(result)

Submission status: Wrong Answer

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

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)
else:
    if n<=a:
        print(n)
    else:
        print(a)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split(' '))
liste = []
break_flag = False
counter = 0
a = 0
b = 0
while counter < N:
    a += A
    b += B
    counter += A+B
if counter > N:
    for i in range(counter-N):
        if break_flag:
            break

        for j in range(B):
            b -= 1
            counter -= 1
            if counter == N:
                break_flag=True
                break
        if break_flag:
            break
        for j in range(A):
            a -= 1
            counter -= 1
            if counter == N:
                break_flag=True
                break

Submission status: Wrong Answer

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

if A==0 and B==0:
    print("0")
    exit(0)

AB = A+B
if N <= AB*1000:
    print ((N-(N//AB)*AB) + ((N//AB)*A))
else:
    print (A*1000)

Submission status: Wrong Answer

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

n = nab[0]
a = nab[1]
b = nab[2]

a_plus_b = a + b

n_waru_ab = n / a_plus_b

if (n_waru_ab.is_integer()):
    print(int(n_waru_ab * a))
else:
    print(int(n_waru_ab * a) + 1)

Submission status: Wrong Answer

Solution code:
def main():
	n,a,b = map(int, input().split())
	if a==0:
		print(0)
	else:
		if n<a:
			print()
		elif a<=n:
			print(a)
		else:
			for i in range(1,10**100):
				if n > (a+b)*i:
					continue
				elif (a+b)*(i-1)<=n:
					print(a*(i-1)+n-(a+b)*(i-1))
					break
main()

Submission status: Wrong Answer

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

print(int(x + y))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
Sum = A + B
if A == 0:
    print('0')
    exit()
ans = (N//Sum) * A
if N < Sum:
    ans += A
    if N < A:
        ans=N
if N >= Sum:
    ans += N - Sum
print(ans)

Submission status: Wrong Answer

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

print(int((N*A+(A+B)-1)/(A+B)))

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))

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

Submission status: Wrong Answer

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

if a + b == n:
    print(a)
    exit()
else:
    if a == 0:
        print(0)
        exit()

while n >= a:
    n -= a + b
    
for i in range(n):
    a += 1

print(a)

Submission status: Wrong Answer

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

all = a + b

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

if N <= a:
    print(N)
    exit(0)
    
# a > 0
roundCnt = round(N / all) * a

if ( N % all ) <= a:
    amariCnt = (N % all)
else:
    amariCnt = a

print(roundCnt + amariCnt)

Submission status: Wrong Answer

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

if A == 0:
    print(0)
else:
    if b <= A:
        print(a*A + b)
    else:
        print(a*(A+1))

Submission status: Wrong Answer

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

if a == 0 and b == 0:
    print("0")
elif a >= n:
    print(n)
else:
    x = n // (a + b)
    if x == 0:
        print(a)
    else:
        print(n - b * x)

Submission status: Wrong Answer

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

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

    return 0
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N , A , B = (map(int , input().split()))
def divmod_(a ,b):
    q, mod = divmod(a ,b)
    return q, mod
c , d = divmod_(N ,A+B)
print((c * A) + d)

Submission status: Wrong Answer

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

x = A + B

num = 1
y = 0
while N <= y:
  y = x * num
  num += 1

if N - num * x <= A:
  print( A * num + ( N - num * x ) )
else:
  print( A * ( num + 1 ) )

Submission status: Wrong Answer

Solution code:
N,A,B=[int(x) for x in input().rstrip().split()]
 
ans=N//(A+B)
amari=N%(A+B)
if B<=amari:
    amari=B
ans1=ans*A+amari
print(ans1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if a >= n:
    print(n)
elif 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:
import math
import sys

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

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

ans = 0
rep = math.ceil(a / (a + b))

ans += min(n, a * (rep))
ans += max(0, n - (a + b) * (rep))

print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
for i in range(10*100):
    if i*(a+b)==n:
        print(a*i)
        exit()
    elif i*(a+b)>n:
        t = n-(i-1)*(a+b)
        if t>a:
            t = a
        print((i-1)*a+t)
        exit()

Submission status: Wrong Answer

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

if A == 0 or N == 0:
    print(0)
else:
    num = int(N / (A + B)) * A
    #print("num:", num)
    num += N % (A + B)
    # print("num:", num)
    
    print(num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

c=(A+B)*(N//(A+B))
s=A*(N//(A+B))

if c+A<=N:
    print(s)
else:
    print(s+N-c)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

zentai_num = N // (A+B)
zentai_b = zentai_num * A


amari_num = N % (A+B)

amari_b = 0
if amari_num >= B:
    amari_b = B
else:
    amari_b = amari_num

# amari_b = max(amari_num - B,0)

# print(amari_num,amari_b)

print(zentai_b + amari_b)

Submission status: Wrong Answer

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

while n > len(box):
    box1 = [('b') for _ in range(a)]
    box2 = [('r') for _ in range(b)]
    box.extend(box1)
    box.extend(box2)
    
m = n - len(box)

if m < 0:
    del box[m:]

print(box, box.count('b'))

Submission status: Wrong Answer

Solution code:
def main():
    N,A,B = map(int, input().split())
    if A == 0:
        print(0)
        return
    if B == 0:
        print(N)
        return
    
    count=0

    sho1 = N // (A+B)
    amari1 = N % (A+B)
    
    if sho1 ==0:
        count += amari1
    else:
        count += sho1*A
        
        sho2=amari1 // A
        amari2=amari1 % A
        
        if sho2 == 0:
            count += amari2
        
        elif sho2 == 1:
            count += A

    print(count)
    
    
main()

Submission status: Wrong Answer

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

if A > 0 & B > 0:
    number = int(N / (A + B))
    r = int(N % (A + B))
    print(A*number + r)
elif A == 0:
    print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#abc 158 b
"""
input().split()
map(int,input().split())
print("Yes" if flag else "No")
for i in range():
"""
n,a,b=map(int,input().split())
ans=0
if a+b>=2:
    ans=n//(a+b)
elif a==0:
    ans=0
elif b==0:
    ans=n
elif n%(a+b)-b<0:
    ans+=n%(a+b)
else:
    ans+=n%(a+b)-b
print(ans)

Submission status: Wrong Answer

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

q,mod=divmod(n,a+b)
print(a*q + mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# n = int(input())
n, a, b = map(int, input().split())
# a = list(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())

import math

n = math.ceil(N/(A+B))
ans =  n * A
if n*(A+B)-N >= B:
  ans -= n*(A+B)-N -B

ans = max(0,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if a==0:
  print(0)
  exit()
elif b==0:
  print(n)
  exit()
s=a+b
cnt=n//s
r=n%s
ans=cnt*a+max(r-b,r)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
	n,a,b = map(int, input().split())
	if a==0:
		print(0)
	else:
		if n<a:
			print()
		elif a<n:
			print(a)
		else:
			for i in range(1,10**100):
				if n > (a+b)*i:
					continue
				elif (a+b)*(i-1)<n:
					print(a*(i-1)+n-(a+b)*(i-1))
					break
main()

Submission status: Wrong Answer

Solution code:
char = input().split(" ")
n = int(char[0])
blue = int(char[1])
red = int(char[2])

num = blue + red

ans = n // num
res = n % num

print(ans * blue + res)

Submission status: Wrong Answer

Solution code:

N, A,B = map(int, input().split())
str = []
for j in range(N//(A+B)+1):
    for i in range(A):
        if i==N+1:
            break
        str.append('b')

    for i in range(B):
        if i==N+1:
            break
        str.append('r')
print(str)
count = 0
for k in range(N):
    if str[k] == 'b':
        count+=1
print(count)

Submission status: Wrong Answer

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

if b >> A:
    print( a * A + A )
else:
    print( a * A + b )

Submission status: Wrong Answer

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

if A==0 and B==0:
    print("0")
    exit(0)

AB = A+B
if N <= (A*B)**1000:
    print ((N-(N//AB)*AB) + (N//AB*A))
else:
    print (A*(10**1000))

Submission status: Wrong Answer

Solution code:
import math

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

if n<(a+b): 
    ans=math.ceil(n/(a+b))*a
else:
    ans=int(n/(a+b))*a + n%(a+b)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

C = A + B

m = N % C
n = N // C

if m == 0:
    print(A*n)
else:
    if m >= A:
        print(A*n)
    else:
        print(A*n + m)

Submission status: Wrong Answer

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

a=N/(A+B)

if A == 0 :
    print(0)

elif N >A+B :
    print(int(a)*A+1)
    
elif N == A+B :
    print(int(a)*A)

elif N < A+B :
    print(N)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

c=a+b
if c==0:
    print(0)
if a==0:
    print(0)
if c!=0 and a!=0:
    d=n//c
    num=n%c+a*d
    print(num)

Submission status: Wrong Answer

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

if A + B == 0:
    print(0)
else:
    c = N // (A + B)
    mod = N % (A + B)
    print(c * A + mod)

Submission status: Wrong Answer

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

all = a + b

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

# a > 0
roundCnt = round(N / all) * a

if ( N % all ) <= a:
    amariCnt = (N % all)
else:
    amariCnt = a

print(roundCnt + amariCnt)

Submission status: Wrong Answer

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

a = int(B+R)
b = int(N/a)
c = int(N%a)

if b <= 0:
    print(B)
elif R == 0:
    print(N)
elif B == 0:
    print(0)
else:
    print((b*B)+c)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

C=(A+B)//N

if A == 0:
    c = 0
else:
    if (A+B)%N >= A:
        C += A+1
    else:
        C += (A+B)%N+1

print(C)

Submission status: Wrong Answer

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

a = int(B+R)
b = int(N/a)
c = int(N%a)

print(R)
if b <= 0:
    print(B)
elif R == 0:
    print(N)
elif B == 0:
    print(0)
else:
    print((b*B)+c)

Submission status: Wrong Answer

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

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 b + r == N:
    print(b)
else:
    print(b + (N - (b + r)))

Submission status: Wrong Answer

Solution code:
a,b,c = map(int,input().split())
d = 0

if b == 0:
    print('0')
    
elif b + c >= a:
    if b < a:
        print(b)
    elif b > a:
        print(a)
    
elif b + c < a:
    if a % (b + c) == 0:
        print((a/(b+c))*b)
    elif a % (b + c) != 0:
        print(int((a/(b+c))*b + (a/(b+c))%b))

Submission status: Wrong Answer

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

if a == 0 and b == 0:
    print("0")
else:
    x = n // (a + b)
    if x == 0:
        print(a)
    else:
        print(n - b * x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if n <= a + b:
    print(a)
else:
    ans = n // (a + b) * a
    if 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())
se = a+b
br = 0
cnt = 0
if a == 0:
    print(0)
elif b == 0:
    print(n)
else:
    cnt = n//(a+b)
    if cnt == 0:
        if n < a:
            print(n)
        else:
            print(a)
    else:
        res = a*cnt
        n -= (a+b)*cnt
        res += n
        print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
for i in range(10*100):
    if i*(a+b)==n:
        print(a*i)
        exit()
    elif i*(a+b)>n:
        t = n-(i-1)*(a+b)
        if t>a:
            t = a
        print((i-1)*a+t)
        exit()
    else:
        continue

Submission status: Wrong Answer

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

if (a+b) == 0:
  print(0)
else:
  trial_num = n // (a + b)
  amari = n % (a + b)
  
  if a == 0:
    print(0)
  else:
    print(trial_num*a + a)

Submission status: Wrong Answer

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

Line = ''

print(N)

while(N > len(Line)):
  for i in range(B):
    Line += 'b'
  for i in range(R):
    Line += 'r'

ans = Line[:N].count('b')

print(ans)

Submission status: Wrong Answer

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

import math
n = math.ceil(N/(A+B))
ans =  n * A
if n*(A+B)-N >= B:
  ans -= n*(A+B)-N -B
print(ans)

Submission status: Wrong Answer

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

all = a + b

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

# a > 0
roundCnt = round(N / all) * a

if ( N % all ) <= a:
    amariCnt = (N % all)
else:
    amariCnt = a

print(roundCnt + amariCnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
Sum = A + B
if A == 0:
    print('0')
    exit()
ans = (N // Sum) * A
if N < Sum:
    ans += N
if N >= Sum:
    ans += N - Sum
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

Submission status: Wrong Answer

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

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

cnt = n//(a+b)
mod = n%(a+b)
if a < mod:
    ans = cnt * (a+1)
else:
    ans = cnt * a + mod

print(ans)

Submission status: Wrong Answer

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

for i in range(10^100):
  blue += a
  total += a
  if total == n:
    print(blue)
    exit(0)
  elif total > n:
    print(blue - (total - n))
    exit(0)
    
  total += b
  if total >= n:
    print(blue)
    exit(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

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

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

print(syou*a + amari)

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b = map(int, input().split())
    if a == 0:
        print(0)
        exit()
    elif b == 0:
        print(n)
        exit()
    c = a + b
    d,e = divmod(n,c)
    f,g = divmod(e,a)
    if f == 0:
        print(a * d + g)
    else:
        print(a * d + a * f)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

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

ans = 0

# 最後の1回前までの処理
while a + b <= n :
    ans = ans + a
    n = n - (a + b)

# 最後の1回の処理
ans = ans + n

print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = [int(i) for i in input().split()]
if a == 0:
  print(0)
else:
  s = n - b
  print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

    print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if 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)