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 = input().split()
N = int(N)
A = int(A)
B = int(B)
C = A + B


mod = N%C
quo = N//C

if mod == 0:
    print(quo*A)
elif A == 0:
    print(0)
elif mod <= A:
    print((quo)*A+mod)
else:
    print((quo)*A+(mod - mod%A))

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(N)
elif b + r >= N:
    print(b)
else:
    if N % (r + b) == 0:
        print(b * (N // (r + b)))
    else:
        print(b * (N // (r + b)) + 1)

Submission status: Wrong Answer

Solution code:
input_line = input().split(" ")
numArray = [int(i) for i in input_line]

if numArray[1] == 0:
  print(0)
elif numArray[2] == 0:
  print(numArray[0])
elif numArray[0] == 1:
  print(1)
elif numArray[0] == (numArray[1] + numArray[2]):
  print(numArray[1])
elif numArray[0] <= numArray[1]:
  print(numArray[0])
else:
  if (numArray[0] % (numArray[1] + numArray[2])) == 0:
    print(numArray[1] * (numArray[0] / (numArray[1] + numArray[2])))
  else:
    blueball = numArray[1] * (numArray[0] // (numArray[1] + numArray[2]))
    number = numArray[0] - (numArray[0] % (numArray[1] + numArray[2]))
    if number < numArray[1]:
      print(blueball + number)
    else:
      print(blueball + numArray[1])

Submission status: Wrong Answer

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

sho = (int)(n / (a + b))
ret = sho * a
ret = ret + (n - sho * (a + b))

print("{}".format(ret))

Submission status: Wrong Answer

Solution code:
n,m,l = map(int,input().split())
x, y = divmod(n, (m + l))
if y <= m:
    print(x*m+y)
else:
    print(x*m+y)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
mm=max(a,b)
if a==0:
    print(0)
    exit()
if b==0:
    print(n)
    exit()
xx=n//mm 
ans=((xx-1)*a)
baaki=n-((xx-1)*a)-((xx-1)*b)
# print(baaki)
while baaki>0:
    temp=min(baaki,a)
    baaki-=temp
    ans+=temp
    if baaki<=0:
        break
    temp=min(baaki,b)
    baaki-=temp
    if baaki<=0:
        break 
print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if a == 0 or n == 0:
  print(0)
else:
  str_length = a + b
  if n <= str_length:
    print(a)
  else:
    v = 10 ** 100
    s = ""
    str_count_all = str_length * v
    if n >= str_count_all:
      print(a*v)
    else:
      mod = str_length - n
      add = mod if mod < a else a
      print(a*(v-1)+add)

Submission status: Wrong Answer

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

list_a=[]
for i in range(a):
    list_a+="a"
list_b=[]
for i in range(b):
    list_a+="b"

list=[]
for i in range(10**100):
    if len(list)>=n:
        break
    else:
        if i%2==0:
            list+=list_a
        else:
            list+=list_b
ans=0
for i in range(n):
    if list[i]=="a":
        ans+=1
    else:
        ()
print(*list)
print(ans)

Submission status: Wrong Answer

Solution code:
data = input().split(" ")
tmp = 0
total = 0
data[0] = int(data[0])
data[1] = int(data[1])
data[2] = int(data[2])
  
data1 = data[1] + data[2]
  
data2 = int(data[0]) / data1
total = data[1]*data2
tmp = data1*data2
data3 = data[0]%data1
  
if (data3 != 0) or (data3 < data[1]):
  total += data3
  
print(int(total))

Submission status: Wrong Answer

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

"""
count = 0
retu = []
while count < 10 ** 100 and count < N:
    count += 1
    for index in range(A):
        retu.append(1)
    for index in range(B):
        retu.append(0)
retu = retu[0:N]
print(sum(retu))
"""

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

Submission status: Wrong Answer

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

S = A+B
count = N//S
pre_cnt = A*count
S_amari  = N-S
if S_amari >= A:
  cnt  = pre_cnt + A
else:
  cnt = pre_cnt + S_amari

print(cnt)

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:
def solve():
    N, A, B = map(int, input().split())

    n_times = N // (A+B)
    amari = N % (A+B)
    cnt = 0
    # if amari != 0:
    #     S = 'b' * A + 'r' * B
    #     S = S[0:amari]

    #     for ball in S:
    #         if ball == 'b':
    #             cnt += 1
    
    print(n_times * A + cnt)

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

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

g = a + b

ans1 = (n % g) * a
ans2 = max(n - ans1 - b, 0)

print(ans1 + ans2)

Submission status: Wrong Answer

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

a2,b2=A**2,B**2
r = (a2-A*B)/(a2-b2)

print (math.ceil(N*r))

Submission status: Wrong Answer

Solution code:
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    
    N,A,B = map(int,input().split())
    C=A+B
    K=N/C
    pp=int(K)*A
    ans=pp+(N%C)
    print(int(ans))
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
'''
ans=""
while len(ans)<N:
    ans+="b"*A
    ans+="r"*B


print(ans[:N].count('b'))
'''

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if a == 0:
    print(0)
    exit()
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())
c = 0

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

if n <= a:
    print(a*c + n)
else:
    print(a*c)

Submission status: Wrong Answer

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

am = n % (b + r)
s  = n // (b + r)

if am <= b:
    print((s * b) + am)
else:
    print(s * (b+1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if A == 0:
  print(0)
elif N > A and A !=0:
  print(int((N*A+(A+B)-1)/(A+B)))
elif N <= A and A !=0:
  print(N)

Submission status: Wrong Answer

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

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:
N, A, B = map(int, input().split())
if A == 0:
  print(0)
if N == A+B:
  print(A)
if N > A+B:
  print(N-B)
if N < A+B:
  print(A)
if N <= A:
  print(N)
else:
  print(A)

Submission status: Wrong Answer

Solution code:
import sys

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

r = bu = 0
bur = a+b
wk = n//bur
bu = wk*a
amari = n%bur

print(bu+min(b,amari))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    (n, a, b) = [int(e) for e in input().split()]
    print((int(n/(a+b)))*a + n%(a+b))

Submission status: Wrong Answer

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

cnt_a = cnt_b = 0

while True:
    if cnt_a + cnt_b + A >= N: 
        # N - cnt_a - cnt_b はみ出た分
        ans = N - cnt_b
        break
    else:
        cnt_a += A
        cnt_b += B

print(ans)

Submission status: Wrong Answer

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

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

if  A == 0 :
    print(0)

elif q < 0 and N <= A:
    print(N)
    
elif q < 0 and N > A:
    print(A)
    
elif q >= 1:
    if mod == 0 :
        print(q*A)
    elif mod <= A :
        print(q*A+mod)
    elif mod > A :
        print(q*A+A)

Submission status: Wrong Answer

Solution code:
import sys

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

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

if a > n:
  print(n)
  sys.exit()

if a+b > n:
  print(a)
  sys.exit()

print(a*q+mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
balls = input().split(" ")

n = int(balls[0])
b = int(balls[1])
r = int(balls[2])

bcnt = min( n, b )

if( n > bcnt ):
  remain = n - b - r
  if( remain > 0 ):
    bcnt += remain
    
print( bcnt )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, S = map(int, input().split())
Blue = 0
red = 0
for i in range(10^100):
    if N > 0:
        N = N - A
        Blue = Blue + A
    if N <= 0:
        Blue = Blue - (-N)
        break
    if N > 0:
        N = N - S
        red = red + S 
    if N <= 0:
        red = red - (-N)
        break
print(Blue)

Submission status: Wrong Answer

Solution code:

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

sum = a+b

if n < a+b:

    if n < a :
        print(n)
    else:
        print(a)

else:
    res = (n // (a+b))*a + n % sum
    print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

b = 0
r = 0

if A > N:
    print(A)
else:
    C = A * (N // (A+B) )
    D = N % (A+B) 
    if D <= A:
        print(C+D)
    else:
        print(C+A)

Submission status: Wrong Answer

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

while n >= 0:
    if n >= a+b:
        n -= (a+b)
        c += 1
    else:
        if n <= a:
            print(a*c + n)
        else:
            print(a*c)
        break

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
    n, a, b = na()
    
    if a == 0 or (a == 0 and b == 0):
        print(0)
        return

    if n <= a:
        print(n)
        return
      
    AB = a + b
    if n <= AB:
        print(min(n, a))
        return 
    
    x = int(n / AB)
    print(x * a + n - (x * AB))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#AtCoder

N, A, B = map(int, input().split())
q, mod = divmod(N,(A+B))
blue = (q*A)

if mod > A:
    blue += (mod-B)
else:
    blue += mod

print(blue)

Submission status: Wrong Answer

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

cnt_a = cnt_b = 0

while True:
    if cnt_a + cnt_b + A >= N: 
        # N - cnt_a - cnt_b はみ出た分
        ans = cnt_a + N - cnt_a - cnt_b
        break
    else:
        cnt_a += A
        cnt_b += B

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N > A:
  print(int((N*A+(A+B)-1)/(A+B)))
else:
  print(N)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
abc = 0
list_a = [a,b]
ans = 0
while abc<1:
    for i in range(10000000000000000000000000000):
        if i % 2 ==0:
            n-=a
            ans+=a
        else:
            n-=b
        if n <=0:
            ans+=n
            abc+=1
            break
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
if A == 0:
    print(A)
    exit()
n = N // (A + B)
nn = N % (A + B)
if n != 0 and nn <= A:
    print(int(A*n + nn))
elif n != 0 and nn > A:
    print(int(A*(n+1)))
elif n == 0 and N > A:
    print(A)
elif n == 0 and N < A:
    print(A - N)

Submission status: Wrong Answer

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

if a == 0:
    print(0)
elif n <= a or b == 0:
    print(n)
elif a < n and n <= a+b:
    print(a)
else:
    mul = n // (a+b)
    mod = n % (a+b) // a
    # print(mul, mod)
    print(mul*a + mod)

Submission status: Wrong Answer

Solution code:
n, a, b = [int(i) for i in input().split()]
x = n // (a + b)
mod = n % (a + b)
diff = abs(a - b)

if diff >= mod:
    print(a * x + mod)
else:
    if n % 2 == 0:
        print(a * (x + 1))
    else:
        print(a * x + mod)

Submission status: Wrong Answer

Solution code:
n, a, b = (int(i) for i in input().split())
q, mod = divmod(ｎ, a+b)
print(b * q + min(mod, a))

Submission status: Wrong Answer

Solution code:
import sys
n,a,b=map(int,input().split())
N=n
A=0
B=0
while 1:
    A+=a

    N-=(a+b)
    if N<=a:
        print(a+N)
        break

Submission status: Wrong Answer

Solution code:
data = input().split(" ")
tmp = 0
total = 0
data[0] = int(data[0])
data[1] = int(data[1])
data[2] = int(data[2])
  
data1 = data[1] + data[2]
  
data2 = int(data[0]) / data1
total = data[1]*data2
tmp = data1*data2
  
if (tmp%data1 != 0) or (tmp%data1 < data[1]):
  total -= data[0] - tmp
  
print(int(total))

Submission status: Wrong Answer

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

list_a=[]
for i in range(a):
    list_a+="a"
list_b=[]
for i in range(b):
    list_a+="b"

list=[]
for i in range(10**100):
    if len(list)>=n:
        break
    else:
        if i%2==0:
            list+=list_a
        else:
            list+=list_b
ans=0
for i in range(n):
    if list[i]=="b":
        ans+=1
    else:
        ()

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
    n, a, b = na()
    
    if a == 0 or (a == 0 and b == 0):
        print(0)
        return

    if n <= a:
        print(n)
        return
      
    if a < n and b == 0:
        print(n)
        return

    AB = a + b
    if n <= AB:
        print(min(n, a))
        return 
    
    x = int(n / AB)
    print(x * a + n - (x * AB))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, a, b = [int(i) for i in input().split()]
x = n // (a + b)
mod = n % (a + b)
diff = abs(a - b)

print(diff, x, mod)
if diff >= mod:
    print(a * x + mod)
else:
    if n % 2 == 0:
        print(a * (x + 1))
    else:
        print(a * x + mod)

Submission status: Wrong Answer

Solution code:

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

sum = a+b

if n<a+b:

    if n<a+b:
        print(a)
    else:
        print(n)

else:
    res = (n // (a+b))*a + n % sum
    print(res)

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

if N >= A:
    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:
import sys

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

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

if a+b > n:
  print(a)
  sys.exit()

print(a*q+mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if(A==0 & B==0):
  print("0")

else:
  r=N//(A+B)
  s=N-A*r
  if(A<s):
    s=A
  if(A!=0):
    t=(A*r)+s
  else:
    t=0
  print(t)

Submission status: Wrong Answer

Solution code:
n, a, b = (int(i) for i in input().split())
q, mod = divmod(ｎ, a+b)
print(b * q + max(mod - a, 0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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:
    if N >= A:
        print(A)
    else:
        print(N)

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:
N, A, B = map(int, input().split())

row = []

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

if N <= A:
    print(N)
    exit()

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

Submission status: Wrong Answer

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

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

if  A == 0 :
    print(0)

elif q < 0 :
    print(N)

elif q >= 1:
    if mod == 0 :
        print(q*A)
    elif mod <= A :
        print(q*A+mod)
    elif mod > A :
        print(q*A+A)

Submission status: Wrong Answer

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

sum = a + b
iter = n // sum
amari = n % sum
if amari >= b:
	print(iter * a + (b))
else:
  print(iter * a + (amari))

Submission status: Wrong Answer

Solution code:
N, A, B = input().split()
N = int(N)
A = int(A)
B = int(B)
C = A + B
sum = C
count = 1

while 1:
    if N > sum:
        sum += C
        count += 1
    else:
        break
# print(count,A,C,N)
mod = N-(count-1)*C
if mod == C:
    print(count*A)
elif A == 0:
    print(0)
elif mod <= A:
    print((count-1)*A+mod)
else:
    print((count-1)*A+(mod - mod%A))

Submission status: Wrong Answer

Solution code:
import sys

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

r = bu = 0
bur = a+b
wk = n//bur
bu = wk*a
amari = n%bur
n -= wk*bur

print(bu+min(b,n))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
t=0
r=0
for _ in range(10^100):
    if n <= t:
        print(r)
        break
    elif n >= a+t:
        t+=a+b
        r+=a
    else:
        r+=min(n-t,a)
        t+=a+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*(int(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:

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

sum = a+b

if n<a:
    print(n)

elif n<a+b:
    print(a)

else:
    res = (n // (a+b))*a + n % sum
    print(res)

Submission status: Wrong Answer

Solution code:
import math
N,A,B = map(int,input().split())
x = A+B
y = N-x
ans = 0
ans += A*(math.floor(N/x))
if y >= A:
  ans += A
else:
  ans += y
print(ans)

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 + (n % (a+b)))

Submission status: Wrong Answer

Solution code:
import sys

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

temp = a // (b+c)
answer = temp * b
temp2 = a % (b+c)

if temp2 >= b:
    answer += b
else:
    answer += temp2

print(temp2)

Submission status: Wrong Answer

Solution code:
import math

N,A,B = list(map(int,input().split()))
tama = []
kaisu = math.ceil(N /(A+ B))
amari = (A+B) * kaisu % N

if N <= A:
    print(N)
elif amari > B:
    print(A* kaisu - (amari -B))
else :
    print(A* (kaisu))

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
    n, a, b = na()
    
    if a == 0 or (a == 0 and b == 0):
        print(0)
        return

    if n <= a:
        print(n)
        return
      
    if a < n and b == 0:
        print(n)
        return

    AB = a + b
    if n <= AB:
        print(min(n, a))
        return 
    
    x = int(n / AB)
    print(x * a + n - AB)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

  s = n // (a + b)
  r = n - (a + b) * s
  
  print(a * s + r)
  
  
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:

def main():
    n, a, b = map(int, input().split())
    flag = True
    res = n
    a_count = 0
    b_count = 0 
    while flag:
        # b
        res -= a
        a_count += 1
        if res == 0:
            flag = False
        # r
        res -= b
        b_count += 1
        if res == 0:
            flag = False
        if res < a:
            flag = False

    print(a_count * a + res )


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

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

sum = a+b

if n<a+b:
    print(n)

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

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)
z = y % (a + 1)

print(a * x + z)

Submission status: Wrong Answer

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:

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

sum = a+b

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

Submission status: Wrong Answer

Solution code:
def input_int_list():
    return [int(thing) for thing in input().split(" ")]
N,A,B=input_int_list()
r=N//(A+B)
if A==0:
    print(0)
    exit()
    
if N-r*(A+B)<=A:
    ans=N-B*r
else:
    ans=A*r

print(ans)

Submission status: Wrong Answer

Solution code:
i = input()
a = i.split(" ")
n = len(i)
if n == 5:
  N = int(a[0])
  A = int(a[1])
  B = int(a[2])
  if A == 0:
    print("0")
  elif N-(A+B) == 0:
    print(A)
  elif A+B != N:
    x = N-(A+B)
    print(A+x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n, a,b=map(int, input().split()) 
X = int(n/(a+b))*a
Y = n%(a+b)
print(X+Y)

Submission status: Wrong Answer

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

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

if q == 0 :
    print(0)

elif mod == 0 :
    print(q*A)
elif mod <= A :
    print(q*A+mod)
elif mod > A :
    print(q*A+A)
elif q < 0 :
    print(N)

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 or N == 0:
    print(0)
if B == 0:
    print(N)
else:
    B = A + B
    q, mod = divmod(N, B)
    num = q * A + mod
    # num = (N // B) * A
    # print("num:", num)
    # num += N % B
    # print("num:", num)
    print(num)

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
maxnum = pow(10,100)
if A == 0:
    print(0)
    sys.exit()
if N <= A:
    print(N)
    sys.exit()
waru,amari = divmod(B,AB)
#waru = (N // AB)
#amari = N % AB
if amari > A:
    amari = A
answer = waru * A + amari

print(answer)

Submission status: Wrong Answer

Solution code:
data = input().split(" ")
tmp = 0
total = 0
data[0] = int(data[0])
data[1] = int(data[1])
data[2] = int(data[2])
  
data1 = data[1] + data[2]
  
while (tmp <= data[0]):
  total = data[1]
  tmp += data1
  
if (tmp%data1 != 0) or (tmp%data1 < data[1]):
  total -= data[0] - tmp
  
print(total)

Submission status: Wrong Answer

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

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

if A == 0:
    print(0)
else:
    if mod > A:
        print(q * A + mod - B)
    else:
        print(q * A + mod)

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

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

if t2 <= b:
  ans = t1 * a + t2
else:
  ans = t1 * a + b

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 = [int(i) for i in input().split()]
s = 0
if a == 0:
  print(0)
else:
  while True:
      n -= (a + b)
      s += n + a
      if n <= a:
          break
print(s)

Submission status: Wrong Answer

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

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

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 A==0:
    print(0)
elif B==0:
    print(N)
else:
    co=0
    i=0
    while (A+B)*i<N:
        i+=1
    co=A*(i-1)+(N-(A+B)*(i-1))
    print(co)

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)
    elif N<num:
        ans=A
    else:
        ans=(A*x)+x


    flag=False


print(ans)

Submission status: Wrong Answer

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

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

else:
  print( a*d + a )

Submission status: Wrong Answer

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

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
x=int(x)
print(x)

Submission status: Wrong Answer

Solution code:
def main():
  n, a, b = list(map(int, input().split()))
  if a == 0:
    return 0
  if b == 0:
    return n
  if n <= a:
    return n
  if (a + b) >= n:
    return a
  
  temp = n - b
  set_count = temp // (a + b)
  mod = temp % (a + b)
  blue_in_mod = 0 if mod <= b else mod - b
  
  return b + (set_count * b) + blue_in_mod
  
print(main())

Submission status: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
if a>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:
N, A, B = map(int, input().split())

if(A==0 & B==0):
  print("0")

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

N,A,B = list(map(int,input().split()))
tama = []
kaisu = math.ceil(N /(A+ B))
amari = (A+B) * kaisu % N

if amari > B:
    print(A* kaisu - (amari -B))
else :
    print(A* (kaisu))

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):
    if n<=a:
        print(n)
    else:
        print(a)
else:
    print(n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def input_int_list():
    return [int(thing) for thing in input().split(" ")]
N,A,B=input_int_list()
r=N//(A+B)
if N-r*(A+B)<=A:
    ans=N-B*r
else:
    ans=A*r

print(ans)