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:
import math

#Maps all three inputs into a variable. N is total, A is blue balls, B is red balls
N, A, B = map(int, input().split())
leftOver = N % (A + B)
divTime = N / (A + B)
#print('leftOver: %s' % leftOver)
#print('divTime: %s' % divTime)

if divTime == 1:
  print(A)
elif divTime != 1:
  if leftOver > A:
    print(math.floor(divTime) * A + A)
  elif leftOver <= A:
    print(math.floor(divTime) * A + leftOver)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(n, a, b):
    return (n // (a+b)) * a + min(a, n % (a+b))

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

Submission status: Accepted

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

Submission status: Accepted

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

from sys import stdin, stderr

def main():
   N, A, B = map(int, stdin.readline().split())
   T = N / (A+B)
   res = A*T
   R = N % (A+B)
   res += min(R, A)
   print(res)

   return 0

if __name__ == '__main__': main()

Submission status: Accepted

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

c = a+b

q = n//c
r = n%c

if r<=a:
    R = r
else:
    R = a

ans = q*a + R 

print(ans)

Submission status: Accepted

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

t1 = N//(A+B)
t2 = min(N%(A+B), A)

print(A*t1+t2)

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((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%(A+B), A))

Submission status: Accepted

Solution code:
N, A , B = list(map(int,input().split()))
BR_set, r_ball  = divmod(N, A+B)
blue_num1 = BR_set * A
if r_ball > A:
    blue_num2 = A
else:
    blue_num2 = r_ball
blue_num = blue_num1 + blue_num2
print(blue_num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

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

a = 0
a = N/(A+B)*A

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

Submission status: Accepted

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

p,q = divmod(N, A+B)
ans = p*A + min(A,q)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

C = A+B
D = int(N/C)
E = A*D
F = N%C

if F>A:
    print(E+A)
else:
    print(E+F)

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n,a,b = map(int,input().split())
if a == 0:
    print(0)
    sys.exit()


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

Submission status: Accepted

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

Submission status: Accepted

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

X = N // (A + B)
Y = N - X * (A + B)

ans = A * X + min(Y, A)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

if y <= a:
  print((x * a) + y)
else:
  print((x * a) + a)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines 
MOD = 10**9+7

N, a, b = map(int, inp().split())
ans = N//(a+b) * a
rest = N%(a+b)
ans += min(a, rest)
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(a, rem)  # ansとremを比較することでnの位置よって処理を変えられる

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import numpy as np

n,a,b=map(int, input().split())
m=n//(a+b)
ans=m*a+min(n-m*(a+b),a)
print(ans)

Submission status: Accepted

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

# ABの並びが何セット入るか
AB_set = N // (A+B)

# あまりは何個か
rest = N % (A+B)
if rest > A:
    print(A * AB_set + A)
else:
    print(A * AB_set + rest)

Submission status: Accepted

Solution code:
import sys
import math

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

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

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

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
q, mod = divmod(N, A+B)
if mod >= A:
	print(q*A+A)
else: 
	print(q*A+mod)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
group = int(N / (A+B))
amari = N % (A+B)
if amari <= A:
    amari_ao = amari
else:
    amari_ao = A
aoi = group * A + amari_ao
print(str(aoi) + '\n')

Submission status: Accepted

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

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

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 math
import itertools
import statistics
#n = int(input())
n, a, b = list(map(int, input().split()))
if n%(a+b) <= a:
    c = n%(a+b)
else:
    c = a
print(n//(a+b)*a+c)

Submission status: Accepted

Solution code:
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    n,a,b = mi()

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






main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


print (W * A + X)

Submission status: Accepted

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

x=int(n/(a+b))
if x*(a+b)+a <= n:
	print(a*(x+1))
else:
	print(n-b*x)

Submission status: Accepted

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

Submission status: Accepted

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

sumAB = A + B
c = N // sumAB
k = N % sumAB
if k < A:
    ans = A * c + k
else:
    ans = A * c + A

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    run()

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())
t=N//(A+B)
m=N%(A+B)
ans=(t*A)+min(m,A)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n, a, b = [int(i) for i in 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())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem,A)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

ans = d*a + min(m, a)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

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

Syo = n //(a+b)
Amari = n%(a+b)


if Amari >= a:
    print(a+a*Syo)
else:
    print(Amari + a*Syo)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
blue = 0
group_len = a + b
quotient = n // (a + b)
blue += quotient * a

mod = n % group_len
if mod <= a:
  blue += mod
else:
  blue += a
  
print(blue)

Submission status: Accepted

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

Submission status: Accepted

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

s=n//(a+b)

amari=n%(a+b)

answer=s*a

if amari>=a:
    answer+=a
else:
    answer+=amari

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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


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

    if N <= A : print(N)    
    else :
        k = N // (A+B)
        rem = N - (A+B)*k
        if  rem >= A:
            print(k*A+A)
        elif rem >= 0:
            print(k*A+rem)
        else : print(k*A)


    return


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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

s = np.array(input().split()).astype(int)
# =============================================================================
# if s.find("A") >= 0 and s.find("B") >= 0:
#     print("Yes")
# else:
#     print("No")
# =============================================================================

N,A,B = s

print(N//(A+B)*A + np.array([N%(A+B),A]).min())

# =============================================================================
# A,B = s
# 
# eight =  100/8
# ten = 100/10
# x1 = A*eight
# x2 = A*ten
# if (int)(A * 10/8) != B:
#     print(-1)
# else:
#     print(np.array(x1,x2).min().astype(int))
# =============================================================================

Submission status: Accepted

Solution code:
num_balls, num_blue, num_red = map(int, input().split())

if num_balls % (num_blue + num_red) <= num_blue:
    print((num_balls // (num_blue + num_red)) * num_blue + num_balls % (num_blue + num_red))
else:
    print((num_balls // (num_blue + num_red))*num_blue + num_blue)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

mul = N // (A+B)

ret = A * mul

m = N % (A+B)

ret += min(m, A)

print(ret)

Submission status: Accepted

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

if i[1] == 0:
    print(0)

else:
    j = i[0] // (i[1] + i[2])
    k = j * i[1]

    l = j * (i[1]+i[2])
    l_max = min(l + i[1], i[0])

    k = k + (l_max - l)
  
    print(k)

Submission status: Accepted

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

C = N//(A+B)

out = C*A + min(N%(A+B),A)

print(out)

Submission status: Accepted

Solution code:

n, a, b = [int(i) for i in input().split()]
sy = n // (a+b)
am = n % (a+b)
print(sy*a + min(am, a))

Submission status: Accepted

Solution code:
#abc158b
n,a,b=map(int,raw_input().split())
if n<=a:
 print n
elif n<=a+b:
 print a
else:
 r=n%(a+b)
 print n/(a+b)*a+min(r,a)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def main():
    N,A,B = map(int,input().split())
    ans0 = N//(A+B)
    ans1 = A*ans0
    ans2 = (N-(A+B)*ans0)
    ans1 += min(ans2,A)
    print(ans1)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def main():
    N,A,B = map(int,input().split())
    ans0 = N//(A+B)
    ans1 = A*ans0
    ans2 = (N-(A+B)*ans0)
    if ans2 <= 0:
        ans2 = 0
    ans1 += min(ans2,A)
    print(ans1)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

ans = shou*a+a if amari >= a else shou*a+amari

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

if amari >= a:
    print(shou * a + a)

else: print(shou * a + amari)

Submission status: Accepted

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

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

if r>a:
    r=a

print(q*a+r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n, a, b = LI()
    ab = a + b
    print(n // ab * a + min(n % ab, a))
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
S=list(map(int,input().split()))
N=S[0]
A=S[1]
B=S[2]
C=A+B
D=N//C
E=N%C
b=A*D
if E>A:
    b+=A
else:
    b+=E
print(b)

Submission status: Accepted

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

if mod <= b:
	print(q * b + mod)
else:
  	print(q * b + b)

Submission status: Accepted

Solution code:
N,A,B = [int(i) for i in input().split()]
K = A +B
m = N // K
ans = A * m
d = N - K * m
if d >= A:
    ans += A
else:
    ans += d
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Author: cr4zjh0bp
# Created: Sun Mar  8 05:03:14 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()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=list(map(int,input().split()))
b=int(a[0]/(a[1]+a[2]))
c=a[0]-b*(a[1]+a[2])
if c>a[1]:
    print(b*a[1]+a[1])
else:
    print(b*a[1]+c)

Submission status: Accepted

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

Submission status: Accepted

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

x=n//(a+b)

if n-x*(a+b)>a:
    print(x*a+a)
else:
    print(x*a+n-x*(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())
# 先頭N個に完全に含まれるループの数
complete_roop = N//(A+B)
ans = complete_roop*A
# あとは端数の中に青いボールがいくつあるかを数える
fraction = min(N%(A+B), A)
ans += fraction
print(ans)

Submission status: Accepted

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

    if amari < a:
        print(syou*a+amari)
    else:
        print((syou+1)*a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7

N, A, B = MI()
p, q = divmod(N, A + B)
print(A * p + min(A, q))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from math import floor

num = [int(_) for _ in input().split()]


col_num = num[1] + num[2]

line = floor(num[0] / col_num)

count = line * num[1]

temp = num[0] % col_num
if temp == 0:
    pass
else:
    count += min(temp,num[1])

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

ans = n // (a + b) * a
alp = min([n % (a + b), a])

print(ans + alp)

Submission status: Accepted

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

times = int(N/(A+B))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

x = N//(A+B)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


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

Submission status: Accepted

Solution code:
n,a,b = input().split()
n,a,b = [int(n), int(a), int(b)]
num = n // (a + b)
ber = n % (a + b)
ans = a * num

if ber > a:
  ans += a
else:
  ans += ber
  
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#python3

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

Submission status: Accepted

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

Submission status: Accepted

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

ab = A + B
q = N // ab
r = N % ab

b1 = q * A
b2 = min(r, A)
print(b1 + b2)

Submission status: Accepted

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

Submission status: Accepted

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

ans += A*(N//(A+B))

if N%(A+B) >= A:
    ans += A
else:
    ans += N%(A+B)

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, A: int, B: int):
    d, m = divmod(N, A+B)
    ans = d*A + min(m, A)
    print(ans)
    return


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,a,b = map(int, input().split())
itr = n//(a+b)
nokori = min(n-(itr*(a+b)),a)
print(itr*a+nokori)

Submission status: Accepted

Solution code:
import math
n,a,b=map(int, input().split())
roop = math.floor(n / (a+b))
anc_a = a*roop
n_b = n-(roop*(a+b))
print(anc_a + min([n_b,a]))

Submission status: Accepted

Solution code:
import math
n,a,b=map(int, input().split())
roop = math.floor(n / (a+b))
anc_a = a*roop
n_b = n-(roop*(a+b))
cnt = anc_a + min([n_b,a])
print(cnt)

Submission status: Accepted

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