Problem:


Score : 200 points

Problem Statement

Takahashi has many red balls and blue balls. Now, he will place them in a row.

Initially, there is no ball placed.

Takahashi, who is very patient, will do the following operation 10^{100} times:

Place A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.

How many blue balls will be there among the first N balls in the row of balls made this way?

Constraints

1 \leq N \leq 10^{18}

A, B \geq 0

0 < A + B \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

Print the number of blue balls that will be there among the first N balls in the row of balls.

Sample Input 1

8 3 4

Sample Output 1

4

Let b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.

Sample Input 2

8 0 4

Sample Output 2

0

He placed only red balls from the beginning.

Sample Input 3

6 2 4

Sample Output 3

2

Among bbrrrr, there are two blue balls.



Sample input:
8 3 4


Sample output:
4

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
# 先頭からN個のボール, 列の末尾にA個の青ボール追加, B個の赤ボール追加

count = A * N // (A + B)
count += min(N - count, A)
print(count)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
s = ''
for _ in range(a):
    s += 'a'
for _ in range(b):
    s += 'b'

s *= 1000

print(s[0:n].count('a'))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if a<=n%(a+b)<(a+b) or n%(a+b)==0:
    print(a*(a+b+n-1)//(a+b))
else:
    print(a*(n//(a+b))+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(str(A*x+y))

Submission status: Wrong Answer

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

x=N//(A+B)
y=N%(A+B)

print(str(A*x+y))

Submission status: Wrong Answer

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

c = a + b
div = n // c
mod = n % c

if mod > a:
    mod -= a

ans = div * a + mod
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = 0
#print (N//(A+B))

sum+=A*(N//(A+B))+(N%(A+B))
print (sum)

Submission status: Wrong Answer

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

ans = 0
if (A + B) != 0:
    taple = divmod(N, A + B)
    ans = taple[0] * A
    if B == 0: ans = N
    elif taple[1] - B >= 0: ans += A
    else: ans += taple[1]

print(ans)

Submission status: Wrong Answer

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

ans = 0
if (A + B) != 0:
    taple = divmod(N, A + B)
    ans = taple[0] * A
    if taple[1] - B >= 0: ans += A
    else: ans += taple[1]

print(ans)

Submission status: Wrong Answer

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

taple = divmod(N, A + B)

ans = taple[0] * A
if taple[1] - B >= 0: ans += A
else:                 ans += taple[1]

print(ans)

Submission status: Wrong Answer

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

taple = divmod(N, A + B)

ans = 0
if taple[1] - B > 0: ans = taple[0] * A + A
else: ans = taple[0] * A + taple[1]

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

al = blue + red

if n >= al:
    s = n // al
    n -= s * al
    ans = blue * s + n
    print(ans)

elif n >= blue:
    print(blue)

else:
    print(n)

Submission status: Wrong Answer

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

al = blue + red

s = n // al

n -= s * al

ans = blue * s + n

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

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())
blue = N//(A+B)*A + N%(A+B)
print(blue)

Submission status: Wrong Answer

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

al = int(z[0])
blue = int(z[1])
red = int(z[2])
s = blue + red

ans = 0

k = al // s

ans += blue * k

ans += al - s * k

print(ans)

Submission status: Wrong Answer

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

al = int(z[0])
blue = int(z[1])
red = int(z[2])
s = blue + red

ans = 0

k = int(al // s)

ans += blue * k

ans += al - s * k

print(ans)

Submission status: Wrong Answer

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

al = int(z[0])
blue = int(z[1])
red = int(z[2])
s = blue + red

ans = 0
k = 0

while k <= al - s:
    ans += blue
    k += s

ans += al - k

print(ans)

Submission status: Wrong Answer

Solution code:
n,A,B=map(int,input().split())
z=A+B
if n%z<=A:
    print(int(n/z)*A+n%z)
elif A<=n%z<=z:
    print(int(n/z)*A)

Submission status: Wrong Answer

Solution code:
n=8
A=3
B=4
z=A+B
if n%z<=A:
    print(int(n/z)*A+n%z)
elif A<=n%z<=z:
    print(int(n/z)*A)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math


def main():

    v = list(map(int, input().split()))
    n = v[0]
    a = v[1]
    b = v[2]

    answer = 0
    if n < a+b:
        answer = a
    elif a == 0 and b == 0:
        answer = 0
    else:
        answer += math.floor(n / (a+b)) * a
        rest = n % (a+b)
        if rest <= a:
            answer += rest
        else:
            answer += a
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():

    v = list(map(int, input().split()))
    n = v[0]
    a = v[1]
    b = v[2]

    answer = 0
    if n < a+b:
        answer = a
    elif a == 0 and b == 0:
        answer = 0
    else:
        answer += int(n / (a+b)) * a
        rest = n % (a+b)
        if rest <= a:
            answer += rest
        else:
            answer += a
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():

    v = list(map(int, input().split()))
    n = v[0]
    a = v[1]
    b = v[2]

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import math

count = 0
num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
count = num // (all_ball)
rest = num % all_ball
print(count * all_ball + min(rest, blue_num))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import math

count = 0
num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if blue_num == 0:
    print(0)
else:
    count = math.floor(num / all_ball)
    rest = num - (count * all_ball)
    if rest == 0:
        print(count * blue_num)
    elif rest <= blue_num:
        blue_rest = rest
        print((count * blue_num) + blue_rest)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import math

count = 0
num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if blue_num == 0:
    print(0)
elif red_num == 0:
    print(num)
else:
    count = math.floor(num / all_ball)
    rest = num - (count * all_ball)
    if rest == 0:
        print(count * blue_num)
    elif rest <= blue_num:
        blue_rest = rest
        print((count * blue_num) + blue_rest)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import math

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if blue_num == 0:
    print(0)
elif red_num == 0:
    print(num)
else:
    count = math.floor(num / all_ball)
    rest = num - (count * all_ball)
    if rest == 0:
        print(count * blue_num)
    elif rest <= blue_num:
        blue_rest = rest
        print((count * blue_num) + blue_rest)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import math

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if blue_num == 0:
    print(0)
elif red_num == 0:
    print(num)
else:
    count = int(math.floor(num / all_ball))
    rest = int(num - (count * all_ball))
    if rest <= blue_num:
        blue_rest = rest
        print((count * blue_num) + blue_rest)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if num or blue_num == 0:
    print(0)
else:
    rest = int(num % all_ball)
    if rest <= blue_num:
        blue = rest
    count = int(num / all_ball)
    print((count) * blue_num + blue)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if blue_num == 0:
    print(0)
else:
    rest = int(num % all_ball)
    if rest <= blue_num:
        blue = rest
    count = int(num / all_ball)
    print((count) * blue_num + rest)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if blue_num == 0:
    print(0)
else:
    rest = num % all_ball
    if rest <= blue_num:
        blue = rest
    count = int(num / all_ball)
    print((count) * blue_num + rest)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if blue_num == 0:
    print(0)
else:
    rest = num % all_ball
    if rest <= blue_num:
        blue = rest
    count = num / all_ball
    print((count) * blue_num + rest)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if blue_num == 0:
    print(0)
else:
    rest = num % all_ball
    if rest < blue_num:
        blue = rest
    count = int(num / all_ball)
    print((count) * blue_num + rest)

Submission status: Wrong Answer

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

p=a+b
c=n%p
d=n//p

if d<a:
  print(c*a+d)
else:
  print((c+1)*a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if A == 0:
    print(0)
elif N >= A+B:
    blue = A * (N // (A+B)) + (N % (A+B))
    print(blue)
elif N < A+B:
    if 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:
    blue = A * (N // (A+B)) + (N % (A+B))
    print(blue)
elif N <= A+B:
    if N < A:
        print(A-N)
    else:
        print(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())

quotient = N // (A + B)
remainder = N % (A + B)

print(quotient * A + remainder)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int , input().split())
 
L = []
i = 0
k = 0
j = 0
P = N // (A + B)

print((P * A) + (N - ((A + B) * P)))

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*a+a)
else:
    a*x+y

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = (int(x) for x in input().split())
if a == 0:
    print('0')
    exit()
count_a = n // (a + b)
leave_a = n % (a + b)
ans = a * count_a + leave_a
print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = (int(x) for x in input().split())
count_a = n // (a + b)
leave_a = n % (a + b)
ans = a * count_a + leave_a
if a == 0:print('0')
else :print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = (int(x) for x in input().split())
ans = 0
count = n // (a + b)

for i in range(0, count):
    ans += a
    n -= a + b
print(ans + n)

Submission status: Wrong Answer

Solution code:
n, a, b = (int(x) for x in input().split())
ans = 0
while 1:
    if n >= a:
        n -= a + b
        ans += a
    else:
        ans += n
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,a,b=map(int,input().split())
if n<=a:
    print(n)
else:
    print(a)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
if N <= A+B:
    print(A)
    exit()
else:
    ans = N//(A+B) * A
    ans += min(A, N%(A+B))
    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())
t=a+b
n=min(n,t*10**100)
if n%t<=a:
    diff=n%t
else:
    diff=a
print(a*n//t+diff)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

if a ==0:
  print(0)
elif a >= n:
  print(n)
elif a + b >n:
  print(a)

else:
  if m2 >= a:
    print(m1 * (a +1))
  else:
    print(m1 * a + m2)

Submission status: Wrong Answer

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

if a ==0:
  print(0)
elif a >= n:
  print(n)
elif a + b >=n:
  print(a)

else:
  if m2 >= a:
    print(m1 * (a +1))
  else:
    print(m1 * a + m2)

Submission status: Wrong Answer

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

if a ==0:
  print(0)
elif a > n:
  print(n)
elif a + b >n:
  print(a)

else:
  if m2 >= a:
    print(m1 * (a +1))
  else:
    print(m1 * a + m2)

Submission status: Wrong Answer

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

if a ==0:
  print(0)
elif a + b >n:
  print(a)
elif a > n:
  print(n)
else:
  if m2 >= a:
    print(m1 * (a +1))
  else:
    print(m1 * a + m2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n<a:
  print(n)
  exit()
  
ans=0  
while n>0:
  n-=a
  ans+=a
  if n<0:
    break
  n-=b
  if n<0:
    break

if n==0:
  print(ans)
else:
  print(ans+n)

Submission status: Wrong Answer

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

ans=0
while n>0:
  n-=a
  ans+=a
  if n<0:
    break
  n-=b
  if n<0:
    break

if n==0:
  print(ans)
else:
  print(ans+n)

Submission status: Wrong Answer

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

i=1
num=a+b
while num<n:
  i+=1
  num*=2

if num==n:
  print(a*i)
else:
  print((a*i)-(num-n-b))

Submission status: Wrong Answer

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

i=1
num=a+b
while num<n:
  i+=1
  num*=2
  
print(num,n)

if num==n:
  print(a*i)
else:
  print((a*i)-(num-n-b))

Submission status: Wrong Answer

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

i=1
num=a+b
while num<=n:
  i+=1
  num*=2
  
if num==n:
  print(a*i)
else:
  print((a*i)-(num-n-b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
import math as mt

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
def main():
    N, A, B = map(int, input().split())

    ab = A + B
    res = N % ab
    print((N // ab) * A + res if res <= A else A)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

x = N//(A+B)
y = (N - x*(A+B))%A
blue=x*A + (A if y>=A else y%A)
print(blue)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

pair = N // (A + B)
remain = N % (A + B)

print(A * pair + remain)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if n > a:
    ans += n-b
else:
    ans += n

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':

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

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':

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

    tmp1 = (n // (a + b)) * a
    tmp2 = n % (a + b)
    print(tmp1+tmp2)

Submission status: Wrong Answer

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

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

if c <= a:
    ans = d * a + c
else:
    ans = d * a + a + (a - c)

print(ans)

Submission status: Wrong Answer

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

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

ans = d * a + c

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N > (A + B):
    print(A * M + N - M * (A + B))
else:
    print(min(N, A))

Submission status: Wrong Answer

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

if N >= (A + B):
    print(A * M + N - M * (A + B))
else:
    print(min(N, A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

N, A, B = map(int, sys.stdin.buffer.read().split())

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

# print(f'{N=} {A=} {B=}')
div, mod = divmod(N, A + B)
# print(f'{div=} {mod=}')
ans = div * A + mod
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

N_syo = N//(A+B)
N_amari = N%(A+B)
ans = 0

if B == 0:
    print(N)

elif N_amari == 0:
    print(N_syo*A)
else:
    ans += N_syo*A
    N -= N_syo*(A+B)
    if N <= B:
        ans += N
        print(ans)
    else:
        ans += B
        print(ans)

Submission status: Wrong Answer

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

N_syo = N//(A+B)
N_amari = N%(A+B)
ans = 0

if N_amari == 0:
    print(N_syo*A)
else:
    ans += N_syo*A
    N -= N_syo*(A+B)
    if N <= B:
        ans += N
        print(ans)
    else:
        ans += B
        print(ans)

Submission status: Wrong Answer

Solution code:
import math

i = [int(x) for x in input().split()]

ans = math.ceil((i[0]/ (i[2] + i[1])) * i[1] )

print (ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#l = list(map(int, input().split()))

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


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

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

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

print (ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
judge = n % 2
if n/2 <= b:
  if judge == 0:
    ans = n/2
  else:
    ans = (n - 1)/2
else:
  ans = 0
print(int(ans))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
judge = n % 2
if n/2 <= b:
  if judge == 0:
    ans = (10**100 - n)/2
  else:
    ans = (10**100 - n - 1)/2
else:
  ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
num=0
while n>0:
    if (n<a+b) and (n<a):
        num+=n
        print(num)
        exit()
    if (n<a+b) and (n>a):
        num+=a
        print(num)
        exit()
    n-=a+b
    num+=a

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
num=0
while n>0:
    if n%(a+b)==0:
        print(a)
        exit()
    if (n<a+b) and (n<a):
        num+=n
        print(num)
        exit()
    if (n<a+b) and (n>a):
        num+=a
        print(num)
        exit()
    n-=a+b
    num+=a

Submission status: Wrong Answer

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

N, A, B = map(int, input().split())
if A == 0:
  print(0)
  exit()
x = N // (A+B)
x = x * A

y = N % (A+B)
if y >= 3:
  y = A

print(x + y)

Submission status: Wrong Answer

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

N, A, B = map(int, input().split())
x = N // (A+B)
x = x * A

y = N % (A+B)
if y >= 3:
  y = A

print(x + y)

Submission status: Wrong Answer

Solution code:
import sys


def main():
    input = sys.stdin.buffer.readline
    n, a, b = map(int, input().split())
    q, mod = divmod(n, a + b)
    print(q * a + mod)


if __name__ == "__main__":
    main()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = list(map(int, input().split()))
a=[]
for i in range(n[1]):
  a.append('b')
for i in range(n[2]):
  a.append('r')
if n[0]-(n[1]+n[2])==1:
  a.append('b')
c = a.count('b')
print(c)

Submission status: Wrong Answer

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

try:
    if((N // (A + B)) != 0):
        blue_num = A * (N // (A + B)) + (N % (A + B) % (A + 1))
    else:
        blue_num = A

except ZeroDivisionError:
    blue_num = 0

print(blue_num)

Submission status: Wrong Answer

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

try:
    blue_num = A * (N // (A + B)) + (N % (A + B) % (A + 1))
except ZeroDivisionError:
    blue_num = 0

print(blue_num)

Submission status: Wrong Answer

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

try:
    blue_num = A * (N // (A + B)) + (N % (A + B) % A)
except ZeroDivisionError:
    blue_num = 0
    
print(blue_num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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