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: Accepted

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

if (A + B) == 0:
    print('0')
else:
    repeat = N // (A + B)
    blue = A * repeat
    remain = N % (A + B)
    if remain > A:
        blue += A
    else:
        blue += remain
    print(str(blue))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N, A, B = (int(i) for i in input().split())
    ans = (N//(A+B)) * A
    print(ans + min(N % (A+B), A))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
l1=input().split(" ")
n=int(l1[0])
a=int(l1[1])
b=int(l1[2])
c=a+b
q=n//c
mod=n%c
sub_b=0
#print(q)
#print(l1)
if l1[1]=="0":
    print("0")
else:
    if mod<a:
        sub_b=mod
    else:
        sub_b=a
    b_c=sub_b+a*q
    print(b_c)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, 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
 
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()

ans = a * (n // (a + b))
n -= (a + b) * (n // (a + b))
ans += min(a, n)

print(ans)

Submission status: Accepted

Solution code:
import math

str = input()

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

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

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

blue_ball = nums[1] * ct + res

print(blue_ball)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, 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

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

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

Submission status: Accepted

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

print(min((a * x) + y, (a * x) + a))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(div * a + min(mod,a))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(A * k + min(m, A))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

a += min(A,b)

print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input().split(" ")
n = int(a[0])
b = int(a[1])
r = int(a[2])
c = n // (b + r)
bb = c * b
d = n % (b + r)
if d >= b:
	bb += b
else:
	bb += d 
print(bb)

Submission status: Accepted

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

Submission status: Accepted

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

if a + b == 0:
    b = 1

x = n // (a + b) * a
# print(x)
y = n % (a + b)
# print(y)

# 余った(色の塊の途中で区切られた)ボールが赤なのか青なのか考える
if y <= a:
    ans = x + y
else:
    ans = x + a

# 11 3 2だとして
# 3 2 3 2 1 y1(青1)
# 12 3 2だとして
# 3 2 3 2 2 y2(青2)
# 13 3 2だとして
# 3 2 3 2 3  y3(青3)
# これらの場合はあまりをそのまま足す

# 14 3 2 だと
# 3 2 3 2 3 1 y4(青3赤1)
# この場合余りを全てたすと赤がまざってしまう

# 15 3 2 だと
# 3 2 3 2 3 2 y0(割り切れるのでそのまま答えが出る)

# つまり青(a)の範囲は0~3なので 
# aがyと同じかそれ以下なら足して
# 違うなら(3+1の状態)a(青3つ)だけ足す


print(ans)

Submission status: Accepted

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


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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

ss = s.split(" ")

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

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


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

ss = s.split(" ")

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


ans = 0
div = N //( A + B ) # A > 0
ans = div * A
# ans += min( N % (A + B) , A)
mod = N % ( A + B )


if mod > A :
  ans += A
else :
  ans += mod

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
N, A, B = map(int, input().split())
tmp = N // (A + B)
ans = 0
ans += tmp * A
N -= tmp * (A + B)
if N > A:
    ans += A
else:
    ans += N
print(ans)

Submission status: Accepted

Solution code:
s = input()

ss = s.split(" ")

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


ans = 0
div = N //( A + B ) # A > 0
ans = div * A
ans += min( N % (A + B) , A)
# mod = N % ( A + B )


# if mod > A :
#   ans += A
# else :
#   ans += mod

print(ans)

Submission status: Accepted

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

# 出力
# 奇数を取得
i = 0
num_loop = int(N / (A+B))
tmp = num_loop * A

mod = N % ((A+B))

if mod > A:
    tmp2 = A
else:
    tmp2 = mod

print(tmp + tmp2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

q, r = divmod(n, (a + b))

answer = a * q + min(a, r)
print(answer)

Submission status: Accepted

Solution code:
#n = int(input())
#s = input()
n,a,b= map(int,input().split())
#da = list(map(int,input().split()))
#a = [int(input()) for i in range(n)]

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

Submission status: Accepted

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

q,r=divmod(n,a+b)

print(q*a+min(a,r))

Submission status: Accepted

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

Submission status: Accepted

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

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

if a>amari:
  print(a*kosuu+amari)
else:
  print(a*kosuu+a)

Submission status: Accepted

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

S = d*A + min(p, A)
print(S)

Submission status: Accepted

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

Submission status: Accepted

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

    length_A_plus_B = A + B # AとBの和
 
    quo = N // length_A_plus_B # 商
    rem = N % length_A_plus_B # 余り

    ans = 0
    if N < length_A_plus_B: # NがAとBの和より小さい時
        if N <= A:
            ans = N
        else:
            ans = A
        print('{}'.format(ans))
        exit() # 処理を抜ける

    ans = quo * A 
    if rem <= A:
        ans += rem
    elif rem > A:
        ans += A
    
    print('{}'.format(ans))



if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

print(ans + min(tmp, A))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

mod = int(N % (A + B))
kake = int(N // (A + B))
if mod <= A:
    print(kake*A + mod)
else:
    print(kake*A + A)

Submission status: Accepted

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

num=n//(a+b)
amari=n-num*(a+b)
ans=num*a+amari if amari<=a else (num+1)*a
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Submission status: Accepted

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

ans=0

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

print(ans)

Submission status: Accepted

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

division = N // (A + B)
count = division * A

count += N - division * (A + B) if A > N - division * (A + B) else A
print(count)

Submission status: Accepted

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

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

ans = A * C + min(A, D)
print(ans)

Submission status: Accepted

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

T = int(N/(A+B))
S = N%(A+B)


if S<A:
	print(T*A+S)
else:
	print(T*A+A)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B
N,A,B = map(int,input().split())
sum = 0
# 商
a = N // (A+B)
sum += a*A
b = N - a * (A+B)
if b <= A:
    sum+= b
else:
    sum+=A
print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

count = n // (a+b)
mod = n % (a+b)

ans = a * count + min(mod, a)
print(ans)

Submission status: Accepted

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

print(a*k+min(am,a))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()

def main():
    N, A, B = MI()
    ans = N//(A+B)*A
    rem = N%(A+B)
    print(ans+min(rem, A))
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

sum = a+b

if n < a+b:

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

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

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

Submission status: Accepted

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 = a
  
print(x*a+z)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, A, B = [int(x) for x in input().strip().split()]
print(N//(A+B)*A+min(N%(A+B), A))

Submission status: Accepted

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

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

    tmp = n % ( a + b )

    if tmp >= a:
        tmp = a

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#B
import sys
n,a,b=map(int,input().split())
if a==0:
    print(0)
    sys.exit()
else:
    s=int(n/(a+b))
    if s==0:
        m=n
    else:
        absum=(a+b)*s
        m=n%(absum)#余り
    if m<a:
        print(s*a+m)
    else:
        print((s+1)*a)

Submission status: Accepted

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

Submission status: Accepted

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

count = N//(A+B)
if (N-count*(A+B))>A:
    print(count*A+A)
else:
    print(count*A+(N-count*(A+B)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print (d)

Submission status: Accepted

Solution code:
N,A,B = list(map(int, input().split()))
q, mod = divmod(N, A+B)
print(A*q + min([mod, A]))

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
def main():
    N, A, B = map(int, input().split(" "))
    if (A + B) == 0:
        print(0)
        return
    amari = N % (A+B)
    kaisuu = N // (A+B)
    print(kaisuu*A+min(amari, A))
main()

Submission status: Accepted

Solution code:
N, A, B = [int(n) for n in input().split()]
if A == 0:
    print(0)
else:
    C, D = divmod(N, A+B)
    print(A*C+min(A, D))

Submission status: Accepted

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

if A == 0:
    print(0)
else :
    q, r = divmod(N, A+B)

    output = q * A

    output += min(r, A)

    print(output)

Submission status: Accepted

Solution code:
# coding: utf-8
N, A, B = map(int, input().split())
# print("N:", N, "A:", A, "B:", B) 
if A == 0:
    print(0)
elif B == 0 or N <= A:
    print(N)
else:
    num = int(N / (A + B)) * A + min(A, N % (A + B))
    print(num)

Submission status: Accepted

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

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

ans += min(rem, a)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

st = N // (A+B)
plus = min(N%(A+B), A)

ans = A * st + plus
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(N: int, A: int, B: int):
    s = N // (A + B)
    add = N - (A + B) * s
    if add < A:
        print(A * s + add)
    elif add >= A:
        print(A * s + A)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)


if __name__ == "__main__":
    main()

Submission status: Accepted

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


def solve(N: int, A: int, B: int):
    s = N // (A + B)
    add = N - (A + B) * s
    if add < A:
        print(A * s + add)
    elif add < A + B:
        print(A * s + A)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
## test

n,a,b=map(int, input().split())
cnt = 0
mode = 0
if a == 0:
    cnt = 0
elif a+b == n:
    cnt = a
else:
    roop = math.floor(n / (a+b))
    anc_a = a*roop
    n_b = n-(roop*(a+b))
    while True:
        if n_b >= a and mode == 0:
            n_b = n_b - a
            cnt += a
            mode = 1
        elif mode == 1:
            n_b = n_b-b
            mode = 0
        elif n_b < a and mode == 0:
            cnt += n_b
            n_b = n_b -a
        if n_b <= 0:
            break
    cnt += anc_a 
print(cnt)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n,a,b = map(int,input().split())
c = a+b

count = int(n/c)*a+min(n%c,a)

print(count)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:

n, a, b = map(int, input().split())
period = a+b
times = n//period
k = n%period
n =  a if k >a else k
print(times*a + n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n,a,b=map(int, input().split())
cnt = 0
mode = 0
if a == 0:
    cnt = 0
elif a+b == n:
    cnt = a
else:
    roop = math.floor(n / (a+b))
    anc_a = a*roop
    n_b = n-(roop*(a+b))
    while True:
        if n_b >= a and mode == 0:
            n_b = n_b - a
            cnt += a
            mode = 1
        elif mode == 1:
            n_b = n_b-b
            mode = 0
        elif n_b < a and mode == 0:
            cnt += n_b
            n_b = n_b -a
        if n_b <= 0:
            break
    cnt += anc_a 
print(cnt)

Submission status: Accepted

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

def main(N, A, B):

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

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

    return sumBlue

if __name__ == "__main__":

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

Submission status: Accepted

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

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

else:
  c = a*int(n//(a+b)) + min(n%(a+b),a)
  print(c)

Submission status: Accepted

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

n = N-((A+B)*kaisu)
if n >= A:
    print(A*(kaisu+1))
else:
    print(A*kaisu+n)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

balls= 0
blue = 0

time = n // (a+b)
tmp = n % (a+b)
if tmp < a:
  blue = time*a + tmp
else:
  blue = (time+1)*a

print(blue)

Submission status: Accepted

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

d1, d2 = divmod(n, a + b)
if(a < d2):
    d2 = a

sum = d1 * a + d2
print(sum)

Submission status: Accepted

Solution code:
import math
N,A,B = map(int,input().split())
c = N%(A+B)
p = math.floor(N/(A+B))
if c >= A:
  print((A*p)+A)
else:
  print((A*p)+c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

    print(ans)

Submission status: Accepted

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+min(a,r)
print(ans)