Problem:


Score : 200 points

Problem Statement

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

Initially, there is no ball placed.

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

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

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

Constraints

1 \leq N \leq 10^{18}

A, B \geq 0

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

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

Sample Input 1

8 3 4

Sample Output 1

4

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

Sample Input 2

8 0 4

Sample Output 2

0

He placed only red balls from the beginning.

Sample Input 3

6 2 4

Sample Output 3

2

Among bbrrrr, there are two blue balls.



Sample input:
8 3 4


Sample output:
4

Submission status: Wrong Answer

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

to = n / (a + b)
print(math.ceil(a * to))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import math
n = math.ceil(N/(A+B))
ans =  n * A
if n*(A+B)-N > B:
  ans -= n*(A+B)-N -B
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = list(map(int, input().split(' ')))
tmp = 0
count = 0
if a == 0:
    print(0)
while count < 10**100:
    n -= a
    tmp += a
    if n <= 0:
        print(tmp + n)
        break
    n -= b
    if n <= 0:
        print(tmp)
        break

Submission status: Wrong Answer

Solution code:

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

cnt = 0
sum = 0
i = 0
if a == 0:
    print(0)
    exit()
while sum + a + b < x:
    i % 2 == 0
    sum += a
    cnt += a
else:
    sum += b

print(cnt + min(x - sum, a))

Submission status: Wrong Answer

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

num = int(N / (A + B)) * A
num += N % (A + B)

print(num)

Submission status: Wrong Answer

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

if A + B == 0:
    print(0)
elif A >= N:
    print(A)
elif A+B >= N:
    print(A)
else:
    res = (N // (A+B))*A
    amari = N % (A+B)
    
    if amari <= A:
        print(res + amari)
    elif amari <= A+B:
        print(res + A)

Submission status: Wrong Answer

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

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

if A == 0:
    print(0)
elif B == 0:
    print(N)
elif A + B == N or A + B > N and N >= A:
    print(A)
elif A + B > N and N < A:
    print(N)
else:
    r = int(N / (A+B))
    q = N % (A+B)
    print(r * A + q)

# -----
# 8 4 2
# bbbbrrbb bb

# 13 4 2
# bbbb rr bbbb rr b

# 2 4 2
# bb

# r = N / (A+B)
# q = N % (A+B)
# r * A + q

Submission status: Wrong Answer

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

if A == 0:
    print(0)
else :
    q1, r1 = divmod(N, A+B)

    output = q1 * A

    q2, r2 = divmod(r1, A)

    if q2 == 1:
        output += A
    else :
        output += r2

    print(output)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

n,a,b=map(int,input().split())
ans=0
if a+b>=2:
    ans=n//(a+b)
elif a==0:
    ans=0
elif b==0:
    ans=n
elif n%(a+b)-b<0:
    ans+=n%(a+b)
else:
    ans+=n%(a+b)-b
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n , a , b  = map(int, input().split())
if a >= n : exit(print(n))
ans = n/(a+b)
print(math.floor(ans*a))

Submission status: Wrong Answer

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

ans=n//(a+b)
ans=a*ans
hoge=n%(a+b)%1
if(hoge>a):
  ans+=hoge-a
else:
  ans+=hoge

print(int(ans))

Submission status: Wrong Answer

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

if n//(a+b) == 0:
    if n >= a:
        ans = a
    else:
        ans = n
else:
    ans = (n//(a+b))*a + (n - (n//(a+b))*(a+b))
    
print(ans)

Submission status: Wrong Answer

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

ope=10**100

amari=ope % (A+B)

ao=min(amari,A)
ao+=(N-amari)//(A+B)*A
if (N-amari)%(A+B) > B:
    ao+=(N-amari)%(A+B)-B

print(ao)

Submission status: Wrong Answer

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


if N>=(A+B):
    amari = N%(A+B)
    syou  = N//(A+B)
    sum = 0
    if syou>=1:
        syou = syou * A
        sum = sum + syou
    sum = sum + amari
    print(sum)
else:
    if N>=A:
        print((N//A)*A)     
    else:
        print(N)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int, input().split())
ans = 0
count = 0
for _ in range(10**100):
  ans += A
  count += A+B
  print(ans,count)
  if count > N:
    ans += min(0,B-(count-N))
    print(ans)
    exit()

Submission status: Wrong Answer

Solution code:
N,A,B = map(int, input().split())
sum=0
d = 0
for i in range(1000):
    sum = sum + A
    d = d + A
    if sum >= N:
        sa = sum - N
        d = d - sa
        break
    sum = sum + B
    if sum >= N:
        break
print(d)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  n, a, b = map(int, input().split(' '))
  
  result = 0
  while n > 0:
    if a >= n:
      n = n - a
    else:
      n = n - a
      n = n - b
    
    result += a
    
  print(result + n)
  
  
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

if (a+b) == 0:
  print(0)
else:
  trial_num = n // (a + b)
  amari = n % (a + b)
  
  if a == 0:
    print(0)
  else:
  	print(trial_num*a + amari)

Submission status: Wrong Answer

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

x,y = divmod(n,a+b)
ans = y

if a > y:
    ans += x*a
elif a == 0:
    ans = 0
else:
    ans = x*(a+1)
print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
ans = []
for i in range(10000):
  for j in range(a):
    ans.append('b')
  for k in range(b):
    ans.append('r')
hints = ans[0:n]
count = 0
for l in hints:
  if l == 'b':
    count += 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
[N, A, B] = list(map(int, input().split()))
pair = A+B
ans = 0
if A != 0:
  num = (N-(N%(pair)))/pair
  if N - num*pair < A:
    ans = A*num + (N - num*pair)
  else:
    ans = A*num + A
  
print(int(ans))

Submission status: Wrong Answer

Solution code:
N,A,B=input().split()
n=int(N)
a=int(A)
b=int(B)
m=n%(a+b)
l=(n-m)/(a+b)
if m>a:
  y=a
else:
  y=m
x=a*l+y
print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print((a*x)+y)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, A, B = [int(y) for y in input().split(' ')]
count = N // (A+B)
residue = N % (A+B)

if A == 0:
  print(0)
elif residue > 0:
  print(count*A + residue)
else:
  print(count*A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans1 = (N//(A+B))*A
ans2 = (N%(A+B))
if ans2 > A:
    ans2 = ans2 -A

ans = ans1 + ans2

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b = map(int, input().split())
    if a == 0:
        print(0)
        exit()
    c = a + b
    d,e = divmod(n,c)
    f,g = divmod(e,a)
    if f == 0:
        print(a * d + g)
    else:
        print(a * d + a * f)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

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

set_count = N // (A+B)
extra = N % (A+B)

if extra <= A:
    print(set_count*A + extra)
    exit()
else:
    print(set_count*A + A)
    exit()

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
if A == 0 and B == 0:
    print(A)
    exit()
a_b = A + B
h = int(N / a_b)
if N % a_b == 0:
    print(A*h)
else:
    s = N % a_b
    if s > A:
        print(h * A + A)
    print(h * A + s)

Submission status: Wrong Answer

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

if n-(a+b) <= a:
	ab+= n-(a+b)
else:
	ab += a
#if n - ab ==  
print(ab)

Submission status: Wrong Answer

Solution code:
N, A, B = list(map(int, input().split()))
S = A + B
X = N % S
Y = N // S

print(X + Y*A)

Submission status: Wrong Answer

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

x = N // (A + B)

ans = 0
if x == 0:
    ans = N
elif N - (A + B)*x > A:
    ans = A * (x + 1)
else:
    ans = N - B * x

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if n % (a + b) > 0:
  ans += n % (a + b)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
N, A, B = list(map(int, input().split(' ')))
S = A + B
count = N // S if S != 0 else 0
mod = N % S if S != 0 and count % 2 == 0 else 0
print(A*count + mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

nokori = n
ans = 0

# 最後の1回前までの処理
while a + b <= nokori :
    ans = ans + a
    nokori = nokori - (a + b)

# 最後の1回の処理
ans = ans + nokori

print(ans)

Submission status: Wrong Answer

Solution code:
# ABC158 B

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

M = A+B

if A == 0:
  ans = 0
else:
  ans = (N // M) * A + N % M

print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
cnt = 0
ans = 0
if n//(a+b) <= 10**100:
    ans += a * n//(a+b)
    cnt += (n//(a+b))*(a+b)
    if n - cnt >= a:
        ans += a
    else:
        ans += max(n - cnt, 0)
else:
    ans += a * 10**100
    cnt += 10**100


print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

NAB=np.array(input().split(" "),dtype=np.int32)

N=NAB[0]
A=NAB[1]
B=NAB[2]

div=int(N/(A+B))
mod=N%(A+B)

blue=0
if(mod<=A):
    blue=mod
else:
    blue=A

print(A*div+blue)

Submission status: Wrong Answer

Solution code:
"""
B - Count Balls
"""

N, A, B = map(int, input().split(' '))
liste = []
break_flag = False
counter = 0

while counter < N:
    if break_flag:
        break
    for j in range(A):
        counter += 1
        liste.append('b')
        if counter == N:
            break_flag = True
            break
    if break_flag:
        break
    for j in range(B):
        counter += 1
        liste.append('r')
        if counter == N:
            break_flag = True
            break
print(liste)
print(liste[:N+1].count('b'))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = [int(x) for x in input().split(" ")]
if (A == 0):
  print(0)
else:
  total_sec = A+B
  print(int(N/total_sec*A) + min(N%total_sec, A))

Submission status: Wrong Answer

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

number = int(N/(A+B))
r = int(N % (A+B))

print(A*number + r)

Submission status: Wrong Answer

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

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

print(num)

Submission status: Wrong Answer

Solution code:
n,a,b  =map(int,input().split())
se = a+b
br = 0
cnt = 0
if a == 0:
    print(0)
elif b == 0:
    print(n)
else:
    cnt = n//(a+b)
    if cnt == 0:
        print(a)
    else:
        res = a*cnt
        n -= (a+b)*cnt
        res += n
        print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if (a+b) == 0:
  print(0)
else:
  trial_num = n // (a + b)
  amari = n % (a + b)

  print(trial_num*a + amari)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if A == 0:
    ans = 0
elif N <= A:
    ans = N
elif N <= A + B:
    ans = min(N, A)
else:
    total = A + B
    i = N // total
    mod = N % total
    ans = A * i + mod

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
for i in range(10*100):
    if i*(a+b)==n:
        print(a*i)
        exit()
    elif i*(a+b)>n:
        t = n-(i-1)*(a+b)
        print((i-1)*a+t)
        exit()
    else:
        continue

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    N,A,B=map(int,input().split())
    count=(N//(A+B))
    if (A+B)*10**100 <= N:
        print(A*10**100)
        return 0
    ans=count*A
    if A>=N-(A+B)*count:
        ans+=(N-(A+B)*count)
        print(ans)
    else:
        print(ans)
main()

Submission status: Wrong Answer

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

ans = 0
ab = a+b

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

ans = n // ab
ans = ans * a + (n%ab)
print(ans)

Submission status: Wrong Answer

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

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

if A>=N:
    print(N)
else:
    if A+B>=N:
        print(A)
    else:
        s, a = divmod(N, A+B)
        print(s*A+a)

Submission status: Wrong Answer

Solution code:
n, a, b = [int(i) for i in input().split()]
if a == 0:
  print(0)
else:
  s = n - a - b + a
  print(s)

Submission status: Wrong Answer

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

mod = N // (A+B)
amari = N % (A+B)
print(mod*A+amari)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

if A==0:
  print(0)
elif N<=A:
  print(N)
elif N<=A+B:
  print(A)
else:
  C=A+B
  q = N // C
  mod = N % C
  
  print(A*q+mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
l = []
for i in range(n):
    for j in range(a):
        l.append("b")
    for k in range(b):
        l.append("r")
print(l.count("b"))

Submission status: Wrong Answer

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

if c > 0:
    ans = a*c + (n - (a+b)*c)
    if ans > (a+b)*(10**100):
        ans = a*(10**100)
else:
    ans = min(a,n)
    
print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if a == 0:
    print(0)
else:
    print(n - b)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

sys.setrecursionlimit(10**9)
mod = 10**7+9
inf = 10**20


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

if n<=a+b:
    l = (a+b)//n
    p = min(n%(a+b),a)
    print((l*a)+p)
else:
    ans = (n//(a+b))*a
    ans += min(n%(a+b),a)
    print(ans)

Submission status: Wrong Answer

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

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

if n < a + b:
  if n < a:
    ans = n
  else:
    ans = a

if a == 0:
  ans = 0
elif b == 0:
  ans = n
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
if A == 0 and B == 0:
    print(A)
    exit()
a_b = A + B
h = int(N / a_b)
if N % a_b == 0:
    print(A)
else:
    s = N % a_b
    if s > A:
        print(h * A + A)
    print(h * A + s)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
ans=0
cnt=0
if A==0 and B==0:
    print(0)
    exit()
if A==0:
    print(0)
    exit()
while(N>=A+B):
    ans+=A
    N-=A+B
ans+=N
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n, a, b = map(int,input().split())
try:
    ans = math.ceil(n / (a + b)) * a + (n % (a + b))
except Exception as e:
    ans = 0
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

br = b + r

a = n / br
a_ = n % br

print(int(a * b + (b if a_ >= b else a_)))

Submission status: Wrong Answer

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

result = A * count
if N % (A+B) != 0:
    result += N - result

print(result)

Submission status: Wrong Answer

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

if A==0:
  print(0)
elif N<=A:
  print(N)
elif N<=A+B:
  print(A)
else:
  C=A+B
  q = N // C
  mod = N % 3
  
  print(A*q+mod)

Submission status: Wrong Answer

Solution code:
import math
a = input().split(" ")
res = int(a[0])
div = int(a[1])+int(a[2])
mult = math.floor(res/div)
plus = res%div
answer = int(a[1])*mult + min([plus,int(a[1])])
answer

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
cnt = 0
ans = 0
if n//(a+b) <= (a+b)*10**100:
    ans += a * n//(a+b)
    cnt += (n//(a+b))*(a+b)
    if n - cnt >= a:
        ans += a
    else:
        ans += n - cnt
else:
    ans += a * 10**100
    cnt += 10**100

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

while len(balls) < n:
    for i in range(a):
        balls = balls + 'a'
        if len(balls) == n:
            break
    for i in range(b):
        balls = balls + 'b'
        if len(balls) == n:
            break
print(balls.count('a'))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,A,B = [int(x) for x in input().split(" ")]
if (A == 0):
  print(0)
total_sec = A+B
print(int(N/total_sec*A) + min(N%total_sec, A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]

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

Submission status: Wrong Answer

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, A, B = list(map(int, input().split()))
C = A + B
result = 0
if A < N:
    q, mod = divmod(N, C)
    result = q * A + mod
else:
    result = N

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
N = a[0]
A = a[1]
B = a[2]
if N%(A+B)!=0:
    repTimes = (N//(A+B)-1) + 1
    bB = repTimes*A
    if N%(A+B) > A:
        extra = A
    else:
        extra = N%(A+B)
    bB += extra
else:
    repTimes = int((N//(A+B)-1))
    bB = repTimes * A
print(bB)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if a==0:
    print(0)
    exit()
    
if a+b>n:
    if a>n:
        print(n)
    else:
        print(a)
else:
    print(n-b)

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b = map(int, input().split())
    if a == 0:
        print(0)
        exit()
    c = a + b
    d,e = divmod(n,c)
    f,g = divmod(e,a)
    print(a * d + a * f + g)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if a==0:
  print('0')
else:
  print(n-b)

Submission status: Wrong Answer

Solution code:
"""
B - Count Balls
"""

N, A, B = map(int, input().split(' '))
liste = []
break_flag = False
counter = 0

for i in range (10**100):
    if break_flag:
        break
    for j in range(A):
        counter += 1
        liste.append('b')
        if counter == N:
            break_flag = True
            break
    if break_flag:
        break
    for j in range(B):
        counter += 1
        liste.append('r')
        if counter == N:
            break_flag = True
            break
print(liste)
print(liste[:N+1].count('b'))

Submission status: Wrong Answer

Solution code:
N,A,B = map(int, input().split())
sum=0
d = 0
for i in range(1000):
    sum = sum + A
    if sum >= N:
        break
    sum = sum + B
    d = d + B
    if sum >= N:
        sa = sum - N
        d = d - sa
        break

print(d)

Submission status: Wrong Answer

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

ans=n//(a+b)
ans=a*ans
hoge=n%(a+b)
if(hoge>a):
  ans+=hoge-a
else:
  ans+=hoge

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

def gcd(a: int, b: int):
    """ https://cocodrips.hateblo.jp/entry/2014/03/05/143623
    """
    while b:
        a, b = b, a%b
    return a

def lcm(a: int, b: int):
    return a * b // gcd(a, b)


def main():
	N,A,B = map(int, input().split())
	#S = input().rstrip()
	#vA = list(map(int, input().split()))
	#vX = [input().rstrip() for _ in [0,]*N]
	
	C = A+B

	res = 0
	
	if N<C:
		res = A
	else:
		res = (N//C) * A
		res += min(N%C, A)
	
	#res = "No" if (S=="AAA" or S=="BBB") else "Yes"
	#res = -(-N//M)
	#res = gcd(N,M)
	print(res)
	
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

N, A, B = list(map(int, input().split()))
cnt = 0
total = 0
blueProcess = True

while total < N:
    if blueProcess:
        cnt += A
        total += A
        blueProcess = False
    else:
        total += B
        blueProcess = True

if total > N:
    cnt -= (total - N)

print(cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if n < a + b:
  ans = a

if a == 0:
  ans = 0
elif b == 0:
  ans = n
print(ans)

Submission status: Wrong Answer

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

# 青がa,赤がb

# n番目の数は赤or青

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

Submission status: Wrong Answer

Solution code:
N, Ablue, Bred = map(int, input().split())

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

ans = N - (Ablue+Bred)
print(ans+Ablue)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

c=a+b
if c==0:
    print(0)
if c!=0:
    d=n//c
    num=n%c+a*d
    print(num)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
ans=0
cnt=0
while(N>=A+B):
    ans+=A
    N-=A+B
if A==0:
    print(0)
    exit()
ans+=N
print(ans)

Submission status: Wrong Answer

Solution code:
[N, A, B] = list(map(int, input().split()))
pair = A+B
ans = 0
if A != 0:
  num = (N-(N%(pair)))/(pair)
  if N - num*pair < A:
    ans = A*num + N - num*pair
  else:
    ans = A*num + N + A
  
print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

set_count = N // (A+B)
extra = N % (A+B)

print(set_count*A + extra)

Submission status: Wrong Answer

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