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:
def main():
    N,A,B=map(int,input().split())
    result=(N//(A+B))*A
    if N%(A+B)>A:
        result+=A
    else:
        result+=N%(A+B)
    print(result)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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)
#ans += rem
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

period = a + b
num_periods = n // period

remainder = n - (a+b)*num_periods

answer = a*num_periods + min(remainder, a)
print(answer)

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

mod=n%(a+b)
if mod>a:
    mod=a

print(str(n//(a+b)*a+mod))

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
n, r = divmod(N, A+B)

ans = A * n  + min(A, r)
print(ans)

Submission status: Accepted

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

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

if n%(a+b) != 0:
    n -= tmp*(a+b)
    if n >= a:
        ans += a
    else:
        ans += n



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:
#!/usr/bin/env python3

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

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

Submission status: Accepted

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

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())
ans = a*(n//(a + b)) + min(a, (n%(a + b)))
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:
#!/usr/bin/env python

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

X = A + B
Y = N // X
Z = N % X

if Z >= A:
  print(A * Y + A)
else:
  print(A * Y + Z)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

q = N//(A + B)
r = N%(A + B)
ans = q*A + min(r,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=map(int,input().split())
x=n%(a+b)
y=n//(a+b)
print(y*a+min(x,a))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from copy import copy
input = sys.stdin.readline
'''
n, m = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
S = input().strip()
for test in range(int(input())):
'''
inf = 100000000000000000  # 1e17
mod = 998244353

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

Submission status: Accepted

Solution code:
# ABC 158: B – Count Balls
N, A, B = [int(s) for s in input().split()]

blues = A * (N // (A + B))
remains = N % (A + B)

if remains < A:
    blues += remains
elif A <= remains < A + B:
    blues += A

print(blues)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# inputを取得
N, A, B = map(int, input().split())

# メインの処理

# 繰り返される組の1組当たりの個数
t = A + B

# Nの中に何組あるか
kumi = N // t

# はみ出た個数
amari = N % t

# はみ出た青の数チェック
if amari >= A:
  amari_ao = A
else:
  amari_ao = amari

# 結果に応じてoutput
print(A * kumi + amari_ao)

Submission status: Accepted

Solution code:
n,a,b = list(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())
 
x = n // (a + b)
d = a * x + min(a, n - (a + b) * x)
print(d)

Submission status: Accepted

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

# n / (blue + red) = quot ... rem
quot = n // (blue + red)  # 商 quotient
rem = n % (blue + red)  # 余り remainder

ans = blue * quot + min(blue, rem)

print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

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

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    N,A,B = MI()
    x = N//(A+B)
    c = N%(A+B)

    if c>A:
        c = A

    print(x*A+c)


if __name__ == "__main__":
	main()

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

Submission status: Accepted

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

Submission status: Accepted

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

c = N // (A + B)

if (A == 0):
    print(0)
    exit()
if (N <= A):
    print(N)
    exit()
elif (N <= (A + B)):
    print(A)
    exit()

if (A + B) * c < N:
    if (N - (A + B) * c <= A):
        print(A * c + N - (A + B) * c)
    elif(N - (A + B) * c > A):
        print(A * c + A)
elif (A + B) * c == N:
    print(A * c)

Submission status: Accepted

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

if m > a:
    m = a

sum_b = a * s + m
print(sum_b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cnt)

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

Submission status: Accepted

Solution code:
N,B,R=map(int,input().split())
b=0
i=int(N/(B+R))
tari=N-(i*(B+R))

b+=B*i
if tari >= B:
    b+=B
else:
    b+=tari

print(b)

Submission status: Accepted

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

Submission status: Accepted

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

blue_ball = 0
if n / (a + b) > 1:
    answer = divmod(n, a + b)
    blue_ball = answer[0] * a
    n = answer[1]

if n > a:
    blue_ball += a
else:
    blue_ball += n

print(blue_ball)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,b,r = list(map(int,input().split()))
block=n//(b+r)
count_b=block*b;
extra_b=n%(b+r);
if(extra_b<=b ):count_b+=extra_b;
else: count_b+=b;
print(count_b)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

blue = 0
if n / (a + b) > 1:
    loop, remain = divmod(n, a + b)
    blue = loop * a
    n = remain

if n > a:
    blue += a
else:
    blue += n

print(blue)

Submission status: Accepted

Solution code:
n, a, b = list(map(int, input().split(' ')))
blueBall = 0
answer = []

if a == 0:
    print(a)
else:
    if n / (a + b):
        answer = divmod(n, (a + b))
        blueBall = answer[0] * a
        if answer[1] > a:
            blueBall = blueBall + a
        else:
            blueBall = blueBall + answer[1]

        print(blueBall)
    else:
        if n <= a:
            print(n)
        elif n <= b:
            print(a)

Submission status: Accepted

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

c = (N//(A+B))* A
d = 0
if N%(A+B) > A:
    d = A
else:
    d = N%(A+B)

print(c + d)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B=[int(s) for s in input().split()]
C=A+B
Q=N//C
R=N%C
if R<=A:
  print(Q*A+R)
else:
  print((Q+1)*A)

Submission status: Accepted

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

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

num = N // (A + B)
res = N % (A + B)

if res > A:
    res = A

ans = num * A + res

print(ans)

Submission status: Accepted

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

AB = A + B

ans = (N // AB) * A
rest = N % AB
if rest < A:
    ans += rest
else:
    ans += A
print(ans)

Submission status: Accepted

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

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

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

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

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

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

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

print(blue)

Submission status: Accepted

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

d = n-c*(a+b)
if d >= a:
    ans = ans + a
else:
    ans = ans + d

print(ans)

Submission status: Accepted

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

sum = 0

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

print(a * A + b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

x = divmod(n, a+b)

if x[1] <= a:
    print(x[0]*a + x[1])
else:
    print(x[0]*a + a)

Submission status: Accepted

Solution code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, A, B = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = N//(A+B)*A + (A if N%(A+B)>A else N%(A+B))
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

c = a + b

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

print(x)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

s=N//(A+B)
NA=N%(A+B)
if(A!=0):
  if(NA<A):
    sA=0
    sAG=NA
  else:
    sA=1
    sAG=0
else:
  sA=0
  sAG=0
print(s*A+sA*A+sAG)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N, A, B = map(int, input().split())
    a, b = divmod(N, (A+B))
    blue = a*A
    if b < A:
        blue += b
    else:
        blue += A
    print(blue)
main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

combo = A + B
num_of_combo = N // combo
remaining = N - combo * num_of_combo

print(num_of_combo * A + min(remaining, A))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

ans=s*a
if we>=a:
  ans+=a
else:
  ans+=we
print(ans)

Submission status: Accepted

Solution code:

url = "https://atcoder.jp//contests/abc158/tasks/abc158_b"

def main():
    a, blue, red = list(map(int, input().split()))
    count, ab_count = divmod(a, blue + red)
    if ab_count > blue:
        ab_count = blue
    print(ab_count + count * blue)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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)

if a == 0:
  ans = 0

print(ans)

Submission status: Accepted

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

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, a, b = mi()
    q = n // (a + b)
    res = n % (a + b)
    print(q * a + min(res, a))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

temp = N % (A+B)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])


# エントリーポイント
def main():
    N, A, B = input([int, 3])
    ans = 0
    ans += N // (A + B) * A
    temp = N % (A + B)
    ans += A if A <= temp else temp
    print(ans)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:



def main():
    NAB = list(map(int,input().split()))




    # tm = NAB[0] // (NAB[1] + NAB[2]) * NAB[1]
    # amari = NAB[0] % (NAB[1] + NAB[2])
    # tm += min(amari,NAB[1])
    #
    # print(tm)

    # b = 0
    #
    # tm = NAB[0]//(NAB[1]+NAB[2])
    # amari = NAB[0] % (NAB[1]+NAB[2])
    #
    # # print(tm)
    # if NAB[1] < amari:
    #     b = (tm*NAB[1])+ NAB[1]
    # else:
    #     b = (tm*NAB[1])+ amari
    #
    # print(b)


    b = 0
    # if NAB[1] == 0:
    #     b = 0
    # elif NAB[2] == 0:
    #     b = NAB[1]

    if NAB[0] < NAB[1]+NAB[2]:
        if NAB[0] < NAB[1]:
            b = NAB[0]
        else:
            b = NAB[1]

    else:
        tm = NAB[0]//(NAB[1]+NAB[2])
        amari = NAB[0] % (NAB[1]+NAB[2])

        # print(tm)
        if NAB[1] < amari:
            b = (tm*NAB[1])+ NAB[1]
        else:
            b = (tm*NAB[1])+ amari

    print(b)





if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:



def main():
    NAB = list(map(int,input().split()))

    # X = NAB[0]
    # a = 0
    # b = 0
    #
    # while X >= 0:
    #     X -= NAB[1]
    #     a += 1
    #     # print("go")
    #
    #     if X <= 0:
    #         break
    #
    #     X -= NAB[2]
    #     b += 1
    #
    # # print(a)
    # # print(b)
    #
    # if b < 0:
    #     print(NAB[1]*a - abs(X))
    # else:
    #     print(NAB[1]*a)



    # tm = NAB[0] // (NAB[1] + NAB[2]) * NAB[1]
    # amari = NAB[0] % (NAB[1] + NAB[2])
    # tm += min(amari,NAB[1])
    #
    # print(tm)

    b = 0

    tm = NAB[0]//(NAB[1]+NAB[2])
    amari = NAB[0] % (NAB[1]+NAB[2])

    # print(tm)
    if NAB[1] < amari:
        b = (tm*NAB[1])+ NAB[1]
    else:
        b = (tm*NAB[1])+ amari

    print(b)


    # b = 0
    # if NAB[1] == 0:
    #     b = 0
    # elif NAB[2] == 0:
    #     b = NAB[1]
    #
    # elif NAB[0] < NAB[1]+NAB[2]:
    #     if NAB[0] < NAB[1]:
    #         b = NAB[0]
    #     else:
    #         b = NAB[1]
    #
    # else:
    #     tm = NAB[0]//(NAB[1]+NAB[2])
    #     amari = NAB[0] % (NAB[1]+NAB[2])
    #
    #     # print(tm)
    #     if NAB[1] < amari:
    #         b = (tm*NAB[1])+ NAB[1]
    #     else:
    #         b = (tm*NAB[1])+ amari

    # print(b)



            # cA = NAB[1]
    # cB = NAB[2]
    #
    # for i in range(NAB[0]):
    #
    #     if NAB[1] == 0:
    #         break
    #     if NAB[2] == 0:
    #         b = NAB[1]
    #         break
    #
    #     if cA != 0:
    #         b += 1
    #         cA -= 1
    #     elif cB != 0 and cA == 0:
    #         cB -=1
    #     else:
    #         cA = NAB[1]
    #         cB = NAB[2]
    #
    #         b += 1
    #         cA -= 1




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:



def main():
    NAB = list(map(int,input().split()))

    # X = NAB[0]
    # a = 0
    # b = 0
    #
    # while X >= 0:
    #     X -= NAB[1]
    #     a += 1
    #     # print("go")
    #
    #     if X <= 0:
    #         break
    #
    #     X -= NAB[2]
    #     b += 1
    #
    # # print(a)
    # # print(b)
    #
    # if b < 0:
    #     print(NAB[1]*a - abs(X))
    # else:
    #     print(NAB[1]*a)

    b = 0

    tm = NAB[0] // (NAB[1] + NAB[2]) * NAB[1]
    amari = NAB[0] % (NAB[1] + NAB[2])
    tm += min(amari,NAB[1])

    print(tm)

    # if NAB[1] == 0:
    #     b = 0
    # elif NAB[2] == 0:
    #     b = NAB[1]
    #
    # elif NAB[0] < NAB[1]+NAB[2]:
    #     if NAB[0] < NAB[1]:
    #         b = NAB[0]
    #     else:
    #         b = NAB[1]
    #
    # else:
    #     tm = NAB[0]//(NAB[1]+NAB[2])
    #     amari = NAB[0] % (NAB[1]+NAB[2])
    #
    #     # print(tm)
    #     if NAB[1] < amari:
    #         b = (tm*NAB[1])+ NAB[1]
    #     else:
    #         b = (tm*NAB[1])+ amari

    # print(b)



            # cA = NAB[1]
    # cB = NAB[2]
    #
    # for i in range(NAB[0]):
    #
    #     if NAB[1] == 0:
    #         break
    #     if NAB[2] == 0:
    #         b = NAB[1]
    #         break
    #
    #     if cA != 0:
    #         b += 1
    #         cA -= 1
    #     elif cB != 0 and cA == 0:
    #         cB -=1
    #     else:
    #         cA = NAB[1]
    #         cB = NAB[2]
    #
    #         b += 1
    #         cA -= 1




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:



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

    # X = NAB[0]
    # a = 0
    # b = 0
    #
    # while X >= 0:
    #     X -= NAB[1]
    #     a += 1
    #     # print("go")
    #
    #     if X <= 0:
    #         break
    #
    #     X -= NAB[2]
    #     b += 1
    #
    # # print(a)
    # # print(b)
    #
    # if b < 0:
    #     print(NAB[1]*a - abs(X))
    # else:
    #     print(NAB[1]*a)

    b = 0

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

    print(tm)

    # if NAB[1] == 0:
    #     b = 0
    # elif NAB[2] == 0:
    #     b = NAB[1]
    #
    # elif NAB[0] < NAB[1]+NAB[2]:
    #     if NAB[0] < NAB[1]:
    #         b = NAB[0]
    #     else:
    #         b = NAB[1]
    #
    # else:
    #     tm = NAB[0]//(NAB[1]+NAB[2])
    #     amari = NAB[0] % (NAB[1]+NAB[2])
    #
    #     # print(tm)
    #     if NAB[1] < amari:
    #         b = (tm*NAB[1])+ NAB[1]
    #     else:
    #         b = (tm*NAB[1])+ amari

    # print(b)



            # cA = NAB[1]
    # cB = NAB[2]
    #
    # for i in range(NAB[0]):
    #
    #     if NAB[1] == 0:
    #         break
    #     if NAB[2] == 0:
    #         b = NAB[1]
    #         break
    #
    #     if cA != 0:
    #         b += 1
    #         cA -= 1
    #     elif cB != 0 and cA == 0:
    #         cB -=1
    #     else:
    #         cA = NAB[1]
    #         cB = NAB[2]
    #
    #         b += 1
    #         cA -= 1




if __name__ == '__main__':
    main()

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)

Submission status: Accepted

Solution code:
def Main(N, A, B):
    di, mo = divmod(N, A+B)
    return di*A + min(mo, A)

def main():
    N, A, B = map(int, input().split())
    print(Main(N, A, B))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from decimal import Decimal
n, a, b = map(Decimal, input().split())
nr = n // (a+b)
nd = n%(a+b)
print(a*nr + min(a,nd))

Submission status: Accepted

Solution code:
N, A, B = (int(x) for x in input().split())
result = 0
if N <= A:
  result = N
elif N > A and N <= A+B:
  result = A
else:
  Q = N//(A+B)
  R = N%(A+B)
  P = N - Q*(A+B)
  if R<= A:
    result = Q*A + R
  else:
    result = Q*A + A
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
N,A,B = list(map(int,stdin.readline().strip().split()))
C=A+B
ans=A*(N//C)
if N%C>A:
    ans+=A
else:ans+=N%C
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 = list(map(int, input().split()))
Amari = N % (A+B)
Show = N // (A+B)

if Amari > A:
    Amari = A
ans = Amari + Show * A
if A == 0:
    ans = 0
print(ans)

Submission status: Accepted

Solution code:
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, A, B = getlist()
	ans = int(N // (A + B)) * A + min(N % (A + B), A)
	print(ans)


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
n, a, b = map(int, input().split())
ans = n // (a+b)
ans *= a
if n % (a+b) != 0:
    ans += min(a, n % (a+b))
print(ans)
'''
i = 0
r = []
for _ in range(10*100):
    for _ in range(a):
        r.append('b')
    for _ in range(b):
        r.append('r')
    
print("".join(r[0:n]))
'''

Submission status: Accepted

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