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

Submission status: Wrong Answer

Solution code:
li = input().split()

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

def firstcheck():
    sum=A+B
    count=A
    i=0
    if(A>=N or A+B>=N):
        return A

    while True:
        if(i%2==0):
            i+=1
            sum+=A
            if(sum>=N):
                count+=(A-(sum-N))
                return count
            else:
                count+=A
                continue
        else:
            i+=1
            sum+=B
            if(sum>=N):
                return count


res=firstcheck()
print(res)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N, A, B = map(int, input().split())
# print("N:", N, "\nA:", A, "\nB:", B)
if A == 0:
    print(0)
else:
    B = A + B
    q, mod = divmod(N, B)
    num = q * A + mod

Submission status: Wrong Answer

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

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


sum = a + b
b = n // sum
p = n % sum
print(p, b)
print((a*b)+p)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n,a,b=map(int,input().split())
if a==0:
    print(0)
    sys.exit()
z=n
n=n%(a+b)
if n==0:
    print(a*n)
else:
    n+=1
    print(a*n-(a-(z-(a+b))))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum_d = A
len_d = A+B
for i in range(1, N//(A+B)):
    sum_d = sum_d + A
    len_d = len_d + A + B
print(sum_d + min((N - len_d), A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,B,R = map(int,input().split())
if B == 0:
  print(0)
if B == 0 and R != 0:
  print(N)
limit = N//(B+R) #genkai
blue = limit * B
print(blue)
red = limit * R
N-=(blue+red)
count = 0
while N > 0 and count < blue:
  N-=1
  blue += 1
  count += 1
  if count == B:
    N-=R
    if N>0:
      count = 0
      continue
print(blue)

Submission status: Wrong Answer

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

answer =0

if A==0:
    answer = 0
elif B==0:
    answer = N
else:
    tail=0
    if N%(A+B) > B:
        tail = B
    else:
        tail = N%(A+B)
    answer = A * (N//(A+B)) + tail

print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = [int(i) for i in input().split()]
x = n // (a + b)
mod = n % (a + b)
if n % 2 != 0:
    if a < b:
        print(a * x + mod)
    else:
        print(a * (x + 1))
else:
    print(a * x + mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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


if n > a + b and n < a + a + b:
    print(a+(n - (a + b)))
    exit()


while True:
    if int(v % (a + b)) > a:
        v -= (a + b)
    elif int(v % (a + b)) <= a:
        print(((n // (a+b)) * a) + v)
        exit()

Submission status: Wrong Answer

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

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

if N >= A + B:
    if A != 0:
        print(A*ans + r)
    else:
        print(0)
else:
    print(A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, b, r = list(map(int, input().split()))
if b==0 and r==0:
  print(0)
  exit()
  
c = N//(b+r)
if N%(b+r) == 0:
  print(b*c)
else:
  if N%(b+r) <= b:
    print(c*b + N%(b+r))
  else:
    print(b*c)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int, input().split())
count=0
flag=True
pattern=True
ans=0
num=A+B
while flag:
    x=N%num
    if A==0:
        ans=0
    elif x==0:
        ans=int((N/num)*A)

    else:
        ans=(A*x)+x


    flag=False


print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
ans = divmod(n, a + b)
print(ans[0] * a + ans[1])

Submission status: Wrong Answer

Solution code:
import numpy as np

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


for i in range(pow(10, 100)):
    if A == 0:
        print('0')
        break
    if B == 0 or N < A:
        print(N)
        break
    if N > A:
        Mod = N % (A + B)
        Quo = int(N / (A + B))
        print(Quo * A + Mod)
        break

Submission status: Wrong Answer

Solution code:
import math


def main():
    N, A, B = map(int, input().split())
    k = N // (A + B)
    g = N % (A + B)

    ans = (k * A) + g

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

    return 0


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if s <= a:
  print( a*d + s )

else:
  print( a*d + a )

Submission status: Wrong Answer

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

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

# 青色(0)の色が0個の時は、すぐに終了させる。
if a == 0:
    print("0")
    exit()

# まず、割り算ですぐに出せる青色の数を出す
bluecount1 = a * (n // (a + b))

if (n % (a+b)) == 0:
    seq = (a+b)
else:
    seq = n % (a+b)

if (n > (a+b)) and (n % (a+b)) != 0:
    if seq <= a:
        bluecount2 = seq
    else:
        bluecount2 = a
else:
    bluecount2 = 0

# print(bluecount1)
# print(bluecount2)

ans = bluecount1 + bluecount2
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N, A, B = map(int, input().split())
# print("N:", N, "\nA:", A, "\nB:", B)
if A == 0:
    print(0)
if B == 0:
    print(N)
else:
    B = A + B
    q, mod = divmod(N, B)
    num = q * A + mod
    print(num)

Submission status: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
if a>b and c>b:
    if b!=0:
        if c==0:
            print(a)
        elif a-b-c>0:
            print(a-c)
        else:
            print(b)
    else:
        print(b)
elif a<b:
    print(a)

Submission status: Wrong Answer

Solution code:
import sys

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

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

print(a*q+mod)

Submission status: Wrong Answer

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s = a*b - n

if s > 0:
  print(s)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
import math

N, A, B = map(int, input().split())
print(math.floor(A * N / (A + B)) + min(A, N % (A + B)))

Submission status: Wrong Answer

Solution code:

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

sum = a+b

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

Submission status: Wrong Answer

Solution code:
N,B,R = map(int,input().split())
k = N % (B + R)
k2 = int(N / (B + R))
#s = ("b"*B + "r"*R)

#s1 = s[:k]
if k >= B:
	print(k2*(B) + k)
else:
	print(k2*(B) + B)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
#B

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

#処理
C=A+B

x=N//C
y=N%C
z=0
z+=x*A
if x==0:
    if A<N:
        z+=A
    else:
        z+=N

else:
    if N-x<y:
        z+=A
    else:
        z+=y

print(z)

Submission status: Wrong Answer

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

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

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

blue = (x * A) + y
print(blue)

Submission status: Wrong Answer

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

res = 0
while(n > 0):
    if n > a:
        n = n - a
        res += a
    else:
        print(res + n)
        sys.exit(0)
    n -= b
print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

if n<=a:
    ans=n
elif n<=(a+b): 
    ans=math.ceil(n/(a+b))*a
elif n%(a+b)==1:
    ans=int(n/(a+b))*a + n%(a+b)
else:
    ans=math.ceil(n/(a+b))*a
print(ans)

Submission status: Wrong Answer

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

if a == 0 and b == 0:
    print("0")
elif a >= n:
    print(n)
else:
    x = n // (a + b)
    if x == 0:
        print(a)
    else:
        if (n - ((a + b) * x)) >= a:
            print(a * x + a)
        else:
            print((a + b) * x)

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)
elif a+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 = map(int, input().split())
# print("N:", N, "\nA:", A, "\nB:", B)
if A == 0:
    print(0)
if B == 0:
    print(N)
else:
    B = A + B
    num = (N//B) * A
    # print("num:", num)
    num += N % B
    # print("num:", num)
    print(num)

Submission status: Wrong Answer

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

line = round(num / (blue + red))
amari = round(num % (blue + red))

b1 = line * blue


if blue > amari:
    print(b1 + amari)
else:
    print(b1 + blue)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
nums = list(map(int, input().split()))
n = nums[0]
a = nums[1]
b = nums[2]

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

Submission status: Wrong Answer

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

if A == 0 :
    print(0)

elif N >A+B :
    q, mod = divmod(N, A+B)
    if mod <= A :
        print(q*A+mod)
    if mod > A :
        print(q*A+A)
    
elif N == A+B :
    q, mod = divmod(N, A+B)
    print(q*A)

elif N < A+B or N < A:
    print(N)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
if A==0:
    print(0)
elif B==0:
    print(N)
else:
    co=0
    i=0
    while (A+B)*i<N:
        co=co+A
        i+=1
    print(co)

Submission status: Wrong Answer

Solution code:
nums = list(map(int, input().split()))
n = nums[0]
a = nums[1]
b = nums[2]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

c = N // (A + B)
mod = N % (A + B)
# print(c,mod)

if mod > A:
    print(c * A + mod - B)
else:
    print(c * A + mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(n * A + N - (A + B) * n)

Submission status: Wrong Answer

Solution code:
N,A,B = input().split(' ')
if int(A)+int(B)==int(N):
    print(A)
elif int(A)==0:
    print(0)
elif int(A)+int(B)<int(N):
    for x in range(int(N)):
        if int(A) + int(B) == int(N):
            A=int(A)+1
        if int(A) + int(B) == int(N):
            break
        else:
            B=int(B)+1
    print(A)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if A == 0 :
    print(0)

elif N >A+B :
    q, mod = divmod(N, A+B)
    if mod <= A :
        print(q*A+mod)
    if mod > A :
        print(q*A+A)
    
elif N == A+B :
    q, mod = divmod(N, A+B)
    print(q*A)

elif N < A+B :
    print(N)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.readline
T = read()
a, b, c = map(int, T.split())

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

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import os


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

    N, A, B = map(int, sys.stdin.readline().split())

    ret = 0
    if N%(A+B) == 0:
        print(int(A*(N/(A+B))))
    elif N < A+B:
        print(min(N, A))
    else:
        ret += A*(N//(A+B))
        if N - (A+B) >= A:
            ret += A
        else:
            ret += N - (A+B)


        print(ret)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, A, B=list(map(int, input().split()))
if A+B==N:
	a=A
else:
    a=A+N-(A+B)
  
    
print(a)

Submission status: Wrong Answer

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

if A >= N:
  print(N)
  
if A < N and A+B >= N:
  print(A)
  
else:
  while b+r < N:
    if b+r+A <= N:
      b += A

      if b+r+B <= N:
        r += B

      else:
        r += N - (b+r)
      
    else:
      b += N - (b+r)
  
  print(b)

Submission status: Wrong Answer

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

res = 0
while(n > 0):
    if n > a:
        n = n - a
        res += a
    else:
        print(res + n)
        sys.exit()
    n -= b
print(a)

Submission status: Wrong Answer

Solution code:
inputarray = input().split(' ')
N = int(inputarray[0])
A = int(inputarray[1])
B = int(inputarray[2])
blue = 'b'
red = 'r'
amari = N % (A+B)
if A >= amari: 
    countnum = A*N//(A+B)+amari
else:
    countnum = A*N//(A+B)+A
print(countnum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

for i in range(pow(10, 100)):
    if A == 0:
        print('0')
        break
    if B == 0 or N < A:
        print(N)
        break
    if N > A:
        print(A)
        break

Submission status: Wrong Answer

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

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

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


if n > a + b and n < a + a + b:
    print(a+(n - (a + b)))
    exit()


while True:
    if v % (a + b) > a:
        v -= (a + b)
    else:
        print(((n // (a+b)) * a) + v)
        exit()

Submission status: Wrong Answer

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

if n<=a:
  print(a)
else:
  q,mod=divmod(n,a+b)
  mod=min(mod,a)
  print(a*q + mod)

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.readline
T = read()
a, b, c = map(int, T.split())

if b == 0:
    print(0)
elif b == 8:
    print(8)
else:
    print(a-c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = input().split(" ")
N = int(K[0])
A = int(K[1])
B = int(K[2])
if B == 0:
    print(0)
else:
    M = N%(A+B)
    L = N//(A+B)
    if M <= A:
        K = L*A+M
    else:
        K = L*A+A
    print(K)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
input_line = [int(i) for i in input().split()]
n = input_line[0]
a = input_line[1]
b = input_line[2]

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

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

Submission status: Wrong Answer

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

i = 0
j = 0
ca = 0
cb = 0
while i+j < n:
    ca += 1
    i += a
    if i+j < n:
        cb += 1
        j += b


if ca < cb:
    print(i)
else:
    print(n-j)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
if A==0:
    print(0)
else:
    co=0
    i=0
    while (A+B)*i<N:
        co=co+A
        i+=1
    print(co)

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%(red+blue)))

Submission status: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
if b!=0:
    if c==0:
        print(a)
    elif a-b-c>0:
        print(a-c)
    else:
        print(b)
else:
    print(b)

Submission status: Wrong Answer

Solution code:
import sys

n,a,b=list(map(int, input().split()))
n = n-(a+b)
i=1


while(n>a or n>b):
  n = n-(a+b)
  i=i+1

print(n+i*a)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

r=N//(A+B)
s=N%(A+B)

if(A!=0):
  t=(A*r)+s
else:
  t=0

print(t)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int, input().split())
count=0
flag=True
pattern=True
ans=0
num=A+B
while flag:
    if N<A:
        ans=N
    elif N<=(A+B):
        ans=A
    else:
        x=N%num
        ans=(A*x)+x


    flag=False


print(ans)

Submission status: Wrong Answer

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

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

if n <= blue:
    print(n)
    exit()

if n <= blue + red:
    print(blue)
    exit()

q = n // (blue + red)
r = n % (blue + red)

cnt = q * blue + (r // blue) * blue + r % blue

print(cnt)

Submission status: Wrong Answer

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

import sys
AB = A+B

if A == 0:
    print(0)
    sys.exit()
waru,amari = divmod(B,AB)
#waru = (N // AB)
#amari = N % AB
answer = waru * A + amari
print(answer)

Submission status: Wrong Answer

Solution code:
nums = list(map(int, input().split()))
n = nums[0]
a = nums[1]
b = nums[2]

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

Submission status: Wrong Answer

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

if a == 0:
    print("0")
if b == 0:
    print(int(n))
else:
    cnt = 0
    ap = 0
    for j in range(0, a):
        box.append("b")
        cnt += 1
    for k in range(0, b):
        box.append("r")
        cnt += 1
    if cnt < n:
        ap = n - cnt

    print(box.count("b") + int(ap))

Submission status: Wrong Answer

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

if a + b == 0:
    x = 1
else:
    x = a + b

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

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

Submission status: Wrong Answer

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

count = - (-N // (A + B)) -1
amari = N%(A+B)
sum_blue = A * count + min(A, amari)
if N >= A + B: sum_blue = A
print(sum_blue)

Submission status: Wrong Answer

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

if n <= a+b:
    if n >= a:
        print(a)
    elif n < a:
        print(n)
elif n > a+b:
    taba = n//(a+b)
    if n-taba*(a+b) >= a:
        print(taba*a+a)
    elif n-taba*(a+b) < a:
        print(taba*a+n)

Submission status: Wrong Answer

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

a = N // (A+B)

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.readline
T = read()
a, b, c = map(int, T.split())

if b == 0:
    print(0)
else:
    print(a-c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = input().split(' ')
if int(A)+int(B)==int(N):
    print(A)
elif int(A)==0:
    print(0)
elif int(A)+int(B)<int(N):
    for x in range(int(N)):
        A=int(A)+1
        if int(A) + int(B) == int(N):
            break
    print(A)

Submission status: Wrong Answer

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

if A > N:
  print(N)
  
if A < N and A+B > N:
  print(A)
  
else:
  while b+r < N:
    if b+r+A <= N:
      b += A

      if b+r+B <= N:
        r += B

      else:
        r += N - (b+r)
      
    else:
      b += N - (b+r)
  
  print(b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
lst = [int(i) for i in input().split()]
ball = lst[0]
blue = lst[1]
red = lst[2]
blue_red = int(ball / (red + blue)) + 1

blue_str = ''
for i in range(blue): blue_str += 'b'
red_str = ''
for i in range(red): red_str += 'r'

mojiretu = ''
for i in range(blue_red):
    mojiretu += (blue_str + red_str)
print(mojiretu[:ball].count('r'))

Submission status: Wrong Answer

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


def count_num_of_blue():
    global N, A, B

    total = 0
    division = int(N / (A+B))
    remainder = int(N % (A+B))
    if division > 0:
        total += A * division

    if remainder < A:
        total += remainder
    else:
        total += remainder

    print(total)


count_num_of_blue()

Submission status: Wrong Answer

Solution code:
number = input().split(" ")
N = int(number[0])
B = int(number[1])
R = int(number[2])

a = int(B+R)
b = int(N/a)
c = int(N%a)

if b <= 0:
    if R ==0:
        print(N)
    else:
        if B > N:
            print(N)
        else:
            print(B)
else:
    if R == 0:
        print(N)
    else:
        if B == 0:
            print(0)
        else:
            print((b*B)+c)

Submission status: Wrong Answer

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()
if A == 0:
    print(0)

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

Submission status: Wrong Answer

Solution code:
input_line = [int(i) for i in input().split()]
n = input_line[0]
a = input_line[1]
b = input_line[2]

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

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

Submission status: Wrong Answer

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

N = X[0]
b = X[1]
r = X[2]

if b == 0:
    print(0)
elif r == 0:
    print(b)
elif b + r == N:
    print(b)
elif b + r < N:
    print(b + (N - (b + r)))
else:
    print(b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
v = n
ans = [] * n
c = 0

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

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


if n > a + b and n < a + a + b:
    print(a+(n - (a + b)))
    exit()


while True:
    if v % (a + b) > a:
        v -= (a + b)
    else:
        print((n * a) + v)
        exit()

Submission status: Wrong Answer

Solution code:
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n, a, b = i2()

if a == 0:
    print(0)
elif b == 0:
    print(n)
else:
    cnt = n // (a+b)
    c = n % (a+b)
    print(cnt,c)
    if c <= a:
        print(a*cnt+c)
    else:
        print(a*cnt+c-(c-a))

Submission status: Wrong Answer

Solution code:
li = input().split()

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

def firstcheck():
    sum=A+B
    count=A
    if(A>=N or A+B>=N):
        return A

    for i in range(int(N)):
        print('he2')
        print(sum)
        if(i%2==0):
            sum+=A
            print("sumhere")
            print("cheksum"+str(sum))
            if(sum>=N):
                count+=(A-(sum-N))
                return count
            else:
                count+=A
        else:
            sum+=B
            if(sum>=N):
                return count


res=firstcheck()
print(res)

Submission status: Wrong Answer

Solution code:
N ,b_int ,r_int = map(int, input().split())


b_count = (N // (b_int + r_int)) * b_int
b_count += N % (b_int + r_int)
    
print(b_count)

Submission status: Wrong Answer

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

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

print(ans)