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

cycle = a + b

count = (n // cycle) * a
if n % cycle == 0:
    pass
elif n % cycle < a:
    count += n % cycle
else:
    count += a

print(count)

Submission status: Accepted

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

print(q+r)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Times = N // (A + B)
rest = N - Times * (A + B)

if rest < A:
        ans = A * Times + rest
else:
        ans = A * Times + A

print(ans)

Submission status: Accepted

Solution code:
def B():
    N, A, B = map(int, raw_input().split())
    nf = N // (A + B)
    return nf * A + min(N - nf * (A + B), A)

print(B())

Submission status: Accepted

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

c = N//(A + B)

rem = N - c * (A + B)

if rem >= A:
	sum = c * A + A
else:
	sum =c * A + rem

print(sum)

Submission status: Accepted

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

div, mod = divmod(n, a+b)
ans = div*a+(mod if mod < a else a)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

count_blue = 0

syou = N // (A + B)
amari = N % (A + B)

if amari > A:
    count_blue = A * syou + A
else:
    count_blue = A * syou + amari

print(count_blue)

Submission status: Accepted

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

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

if e >= a:
    f += a

else:
    f += e

count = a * d + f
print(count)

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:
inf = input().split()
info = list(map(int, inf))
o = info[1] + info[2]
if o == 0:
    print(0)
else:
    q, mod = divmod(info[0], o)
    if mod > info[1]:
        print((q+1)* info[1])
    else:
        print(q*info[1] + mod)

Submission status: Accepted

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

Submission status: Accepted

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

phrase = A + B

ans = N // phrase * A
ans += N % phrase if N % phrase <= A else A
print(ans)

Submission status: Accepted

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


main()

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 = [int(x) for x in input().strip().split()]
p = N // (A + B) * A
q = N % (A + B)
if q > A:
    q = A
print(p + q)

Submission status: Accepted

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

Submission status: Accepted

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

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

if amari >= a:
    tsuika = a
else:
    tsuika = amari

ans = syou * a + tsuika

print(ans)

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

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
N = a[0]
A = a[1]
B = a[2]
count = 0
i = N % (A + B) 
j = N //(A + B)
if i >= A:
  i = A
count = j * A + i
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

q, r = divmod(N, A + B)
res = q * A + A if r > A else q * A + r

print(res)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())
if (A == 0):
    print('0')
elif (B == 0):
    print(N)
else:
    sum = A + B
    div = N // sum
    mod = N % sum
    plus = mod - A
    if (plus > 0):
        ans = div*A + A
        print(ans)
    else:
        ans = div*A + mod
        print(ans)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
def CountBall_158():
    N, A, B = [int(_) for _ in input().split()]
    X = int(N / (A + B))
    Y = int(N % (A + B))
    if Y > A:
        Y = A
    print(A * X + Y)

if __name__ == "__main__":
    CountBall_158()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


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

    r1 = n // (a + b)
    r2 = n % (a + b)

    r = r1 * a + min(r2, a)
    print(r)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
nancy,alpha,beta = map(int,input().split())
delta = nancy // (alpha+beta)
echo = nancy % (alpha+beta)
print(delta * alpha + min(echo, alpha))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(value)

Submission status: Accepted

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

Submission status: Accepted

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

step1 = (N // (blue + read)) * blue
if N % (blue + read) <= blue:
  step2 = N % (blue + read)
else:
  step2 = blue
result = step1 + step2
print(result)

Submission status: Accepted

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

c=a+b

q, mod=divmod(n,c)

A=q*a+min(mod,a)


print(A)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
import os, sys

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

rep = N // (A+B)
rest = N - (A + B) * rep

# diff = A if rest >= A else rest  
ans = A * (rep) + min(rest, A)

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

Submission status: Accepted

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

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

res = count * a
if mod > a:
  res += a
else:
  res += mod
 
print(res)

Submission status: Accepted

Solution code:
N,A,B = (int(x) for x in input().split())
if A == 0:
  print(0)
elif 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())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

ans = q * a + m if m < a else q * a + a

print(ans)

Submission status: Accepted

Solution code:
Nf,Af,Bf = (input().split(' '))
N = int(Nf)
A = int(Af)
B = int(Bf)
a = N % (A + B)
b = N // (A + B)

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

Submission status: Accepted

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

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

cnt = a*r + min(n - r*(a+b), a)

print(cnt)

Submission status: Accepted

Solution code:
inp = input().split()
inp = [int(i) for i in inp]
N, A, B = inp
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
ad = n%(a+b)
ans = ans + ad if ad < a else ans + a
print(ans)

Submission status: Accepted

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

amari = N % (A + B)
sho = N // (A + B)

blue_num = 0

if amari < A:
    blue_num += A * sho + amari
else:
    blue_num += A * sho + A

print(blue_num)

Submission status: Accepted

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

amari = N % (A+B)
sho = N // (A+B)

blue_num = 0
if amari <= A:
    blue_num += A * sho + amari
else:
    blue_num += A * sho + A
    
print(blue_num)

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
res=0
N1=N//(A+B)
N2=N%(A+B)
if A==0:
    res=0
elif B==0:
    res=N
else:
    res1=(N1)*A
    if A<=N2:
        res2=A
    else:
        res2=N2
    res=res1+res2
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

div, mod = divmod(N, A + B)
print(A * div + min(A, mod))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, red, blue = map(int, input().split())
unit = red + blue
print((n // unit) * red + min([n%unit, red]))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ball)

Submission status: Accepted

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

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

count = 0

most = N//(A+B)
amari = (N - (A+B)*most)

if amari <= A:
    print((most*A) + amari)
else:
    print((most*A) + A)

Submission status: Accepted

Solution code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')


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

k=n//(a+b)
m=n-k*(a+b)

l=min(m,a)

print(k*a+l)

Submission status: Accepted

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

q,mod = divmod(N,A+B)

if mod > A:
  mod = A

print(q*A+mod)

Submission status: Accepted

Solution code:
# A = [list(map(int, input().split())) for _ in range(3)]
# n = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
n, b, r = map(int, input().split())
total = b+r
circle = n//total
diff = n % total
if b <= diff:
    print(b + circle*b)
else:
    print(diff + circle*b)

Submission status: Accepted

Solution code:
# A = [list(map(int, input().split())) for _ in range(3)]
# n = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
n, a, b = map(int, input().split())
total = a+b
diff = n % total
blue_in = n//total*a
if a <= diff:
    print(a+blue_in)
else:
    print(diff+blue_in)

Submission status: Accepted

Solution code:
# A = [list(map(int, input().split())) for _ in range(3)]
# n = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
n, a, b = map(int, input().split())
total = a+b
diff = n-((n//total)*total)
omake = n//total*a
if a <= diff:
    print(a+omake)
else:
    print(diff+omake)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

ball = list(map(int, input().split()))

if ball[1] == 0:
    print(0)
    sys.exit()

if ball[2] ==0:
    print(ball[0])
    sys.exit()

number = ball[0]%(ball[1]+ball[2])

if number > ball[1]:
    number = ball[1]

print((ball[0]//(ball[1]+ball[2]))*ball[1]+number)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

mod = n % (blue+red)
if mod <= blue:
    print(blue*(n//(blue+red))+mod)
else:
    print(blue*(n//(blue+red))+blue)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

X = math.floor(N/(A+B))

if N-(A+B)*X < A:
	print(X*A + N -(A+B)*X)
else:
	print(X*A+A)

Submission status: Accepted

Solution code:
import math

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

QUO = math.floor(N / (A + B))

if N - (A + B) * QUO < A:
  print(QUO * A + N - (A + B) * QUO)
  
else:
  print(QUO * A + A)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, A, B = list(map(int, sys.stdin.buffer.readline().split()))
    n = N//(A+B)
    m = N%(A+B)
    print(A*n + min(m, A))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, A, B = list(map(int, sys.stdin.buffer.readline().split()))
    n = N//(A+B)
    m = N%(A+B)
    print(A*n + min(m, A) if m > A else A*n + m)


if __name__ == '__main__':
    main()

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:
#Ａ２　Ｂ４ N10
#AABBBBAABB.BBAABBBB
#NまでにAは何個か

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

bai=int(N/(A+B))
amari=N%(A+B)
#print(bai,amari)

if amari>A:
    nokoriA=A
else:
    nokoriA=amari

sumA=bai*A+nokoriA
print(sumA)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
m = input().split()
N = int(m[0])
A = int(m[1])
B = int(m[2])

sum = A + B
quo = N // sum
rem = N % sum

if A >= rem:
  ans = quo * A + rem
else:
  ans = (quo + 1) * A

print(ans)

Submission status: Accepted

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

count = n // (blue + red)
amari = n % (blue + red)

if amari > blue:
    amari = blue

print(amari + count * blue)

Submission status: Accepted

Solution code:
# coding:utf-8


from math import floor

import numpy as np

strInput = input()
N, A, B = np.array(strInput.split(' ')).astype(int)
numGroup = floor(N / (A + B))
numExtendBall = N % (A + B)
if numExtendBall >= A:
    numExtendBlueBall = A
else:
    numExtendBlueBall = numExtendBall
print(numGroup * A + numExtendBlueBall)

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

quotient = n //(a+b)
remain = n % (a+b)

if remain > a:
    remain = a

print(remain + quotient*a)

Submission status: Accepted

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

pattern = (n // (a + b)) * a
diff = n % (a + b)

count = 0
count += pattern + min(a, diff)

print(min(count, a * (10 ** 100)))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# 158-B
n, a, b = list(map(int, input().split()))
count = -1
if n == 0:
    count = 0
else:
    e_1 = int(n / (a+b)) * a
    e_2 = min(n%(a+b), a)
    count = e_1 + e_2
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

if A[0]%(A[1]+A[2])>=A[1]:
  amari = A[1]
else:
  amari = A[0]%(A[1]+A[2])
print(A[0]//(A[1]+A[2])*A[1] + amari)

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

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
c = a[0]//(a[2]+a[1])*a[1]
c += min(a[1],a[0]%(a[2]+a[1]))
print(c)

Submission status: Accepted

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

Submission status: Accepted

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

reply = text[0] // (text[1] + text[2]) * text[1]

reply += text[1] if text[0] % (text[1] + text[2]) > text[1]else text[0] % (text[1] + text[2])

print(reply)

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc158/tasks/abc158_b
# -*- coding: utf-8 -*-
N,A,B = map(int,input().split())
syou = N//(A+B)
amari = N%(A+B)
if amari>A:
  amari=A
ans = syou*A+amari
print(ans)

Submission status: Accepted

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

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

x = (N // (A + B)) * A 
mod = N % (A + B)
if mod <= A :
    z = mod
else :
    z = A

print(x + z)

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split())  # 複数の数字を変数に格納

sum = A + B
ans = int(N / sum)
les = N % sum

if les < A:
    print(ans * A + les)
else:
    print(ans * A + A)

Submission status: Accepted

Solution code:
import math
input_line = input().split()

N = int(input_line[0])
A = int(input_line[1])
B = int(input_line[2])
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())
c = 0
d = a+b
if a==0:
    print(0)
else:   
    q, mod = divmod(n, d)
    if mod<=a:
        print(q*a +mod)
    else:
        print(q*a +a)

Submission status: Accepted

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

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:
n, a, b = map(int, input().split())
ab = a + b
nab = n // ab
jouyo = n % ab

if ab == n:
    print(a)
elif a == 0:
    print(a)
elif ab < n:
    naba = nab * a
    if jouyo <= a:
        print(naba + jouyo)
    else:
        print (naba + a)
elif ab > n:
    if n <= a:
        print(n)
    else:
        print(a)

Submission status: Accepted

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

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

N %= A + B

ans += A if N > A else N

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
N, A, B = [int(_) for _ in stdin.readline().rstrip().split()]
ans = N // (A + B) * A
mod = N % (A + B)
ans += min(A, mod)
print(ans)

Submission status: Accepted

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


sum=0

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

    # print(a)
    # print(b)
    if b>=A:
        sum=A*a+A
        print(sum)
    if b<A:
        sum=A*a+b
        print(sum)

Submission status: Accepted

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

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

z = x * A + min(y, A)

print(z)

Submission status: Accepted

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

else:
  res += n - (a + b) * d
print(res)

Submission status: Accepted

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

number = n // (blue + red)          
count_blue = number * blue          
number2 = n - number * (blue + red) 
if blue ==0:
    print("0")
    exit()
if number2 > blue:
    count_blue += blue
else:
    count_blue += number2

print(count_blue)

Submission status: Accepted

Solution code:
args = input()
nums = args.split(' ')
n = int(nums[0])
a = int(nums[1])
b = int(nums[2])
blue_calc = int(n / (a + b))
blue_mod = n % (a + b)
if blue_mod < a:
  print(a * blue_calc + blue_mod)
  exit()
print(a * blue_calc + a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


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

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(rem, A)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=[int(e) for e in input().split()]
A=N[0]//(N[1]+N[2])*N[1]
M=N[0]%(N[1]+N[2])
if N[1]>M:
    A+=M
else:
    A+=N[1]
print(A)

Submission status: Accepted

Solution code:
import math

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

num = math.floor( n/(a+b) ) * a

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

print(num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
line = input().split()
N = int(line[0])
A = int(line[1])
B = int(line[2])

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

Submission status: Accepted

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

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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,A,B=map(int,input().split())
C=A+B
D=N//C
count=D*A
N=N-C*D
while N>0:
    N=N-A
    if N>0:
        count=count+A
    elif N<=0:
        count=count+(A+N)
        break
    N=N-B
    if N<=0:
        break
    else:
        pass
print(count)

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:
import math
list = input().rstrip().split(" ")
n = int(list[0])
a = int(list[1])
b = int(list[2])
n_num = n / (a + b) #N個の中にAB周期がいくつあるか
n_number = int(math.floor(n_num)) #↑の整数部分
a_num = n_number * a #周期内のAの数
n_amari = n % (a + b) #周期外のボールの数
n_min_a = n_amari - a #Nあまり引くA
if n_min_a >= 0:
  a_total = a_num + a
else:
  a_total = a_num + n_amari
print(a_total)

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:
# coding: utf-8
# 標準入力 <int><int>
N, A, B = map(int, input().split())

shou = N // (A + B)
amari = N % (A + B)

ans = A * shou

if amari <= A:
    ans += amari
else:
    ans += A

print(ans)

Submission status: Accepted

Solution code:
a,b,c=input().strip().split(" ")
a,b,c=[int(a),int(b),int(c)]
p=b+c
x=a//p
m=a%p
pp=min(b,m)
print(pp+x*b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# スペース区切りの文字列の入力
st = input().split()
#商
div = int(st[0]) // (int(st[1]) + int(st[2]))
#余り
rem = int(st[0]) % (int(st[1]) + int(st[2]))

if(rem < int(st[1])):
  print(div * int(st[1]) + rem)
else:
  print(div * int(st[1]) + int(st[1]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

f = n // (a+b)
g = n % (a+b)

if g <= a:
    print(a * f + g)
    
else:
    print(a * (f+1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin


def get_result(data):
    N, A, B = data
    if A == 0:
        return 0

    remainder = N % (A+B)
    tmp = remainder if remainder < A else A
    quotient = N // (A+B)
    ans = A * quotient + tmp
    return ans


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip('\n').split(' ')))
    result = get_result(data)
    print(result)

Submission status: Accepted

Solution code:
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=map(int,input().split());B+=A;print(N//B*A+min(N%B,A))

Submission status: Accepted

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

c = a + b

ans = n // c * a

if(n%c <= a):
  ans += n%c
else:
  ans += 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())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

q, mod = divmod(N, A+B)

if A < mod:
	mod_A = A
else:
	mod_A = mod

print(A * q + mod_A)