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: Runtime Error

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

s = 'A'*a
s += 'B'*b
ans = s[0:n]
print(ans.count('A'))

Submission status: Runtime Error

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

ball=""
cnt=0

for i in range(n//(a+b)+1):
    ball+="b"*a
    ball+="r"*b
for i in range(n):
    if ball[i]=="b":
        cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
import math
i = input().split()
n = int(i[0])
blue = int(i[1])
red = int(i[2])
line = "b"*blue + "r"*red
nannbai = math.ceil((n/(blue+red)))
line = line*nannbai
line = line[0:n]
line = line.replace("r", "")
print(len(line))

Submission status: Runtime Error

Solution code:
n, a, b = [int(i) for i in input().split()]
x = (n // (a + b)) + 1
balls = [*["b"] * a, *["r"] * b] * x
ans = 0
for i in range(n):
    if balls[i] == "b":
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
n,a,b = input().split()
flag = True
s = ''
if (a!='0'):
    s += 'b'*int(a) + 'r'*int(b)
while flag:
    if (len(s)<int(n) and int(a)!=0):
        s += 'b'
    else:
        flag = False
print(s.count('b') if a!='0' else 0)

Submission status: Runtime Error

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

list_a="a"*a
list_b="b"*b
if a==0:
    print(0)
    sys.exit()
a_l=int(n/(a+b))
b_l=n%(a+b)
if b_l > a : b_l =a
print(a_l*a+b_l)

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
ballb=[]
ballr=[]
ballb.append('b')
ballb=ballb*A
ballr.append('r')
ballr=ballr*B
ball=(ballb+ballr)*N
count=0
for i in range(N):
    if ball[i]=='b':
        count+=1
print(count)

Submission status: Runtime Error

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

    ans = 0

    b = 'b'*A
    r = 'r'*B
    br = b + r

    if(N > 0 and A >= 0 and B >= 0):
        result = br * (N // (A+B) + 1)

        for i in range(N):
            if(result[i] == 'b'):
                ans+=1

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
period = a+b
times = n//period
k = n%period
n =  a if k >a else k
print(times*a + n)
---------------------------
a, b = [int(x) for x in input().split()]
 
if (b < a):
    temp = b
    b = a
    a = temp

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
ballb=[]
ballr=[]
ballb.append('b')
ballb=ballb*A
ballr.append('r')
ballr=ballr*B
ball=(ballb+ballr)*N
count=0
for i in range(0,N):
    if ball[i]=='b':
        count+=1
print(count)

Submission status: Runtime Error

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

Line1 = ("b"*A+"r"*B)
Line2 = ("b"*A+"r"*B)
Cnt = 0
while Cnt < N:
	Line2 += Line1
	Cnt += 1

print(Line2[:N].count("b"))

Submission status: Runtime Error

Solution code:

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

row = ''

while len(row) <= N:
    row += '1' * A
    row += '0' * B

print(row[:N].count('1'))

Submission status: Runtime Error

Solution code:
import numpy as np

n, a, b=map(int,input().split())
k = n / (a + b)
l = n % (a + b)
res = k * a + l
print(res.astype(int))

Submission status: Runtime Error

Solution code:
#B
import sys
n,a,b=map(int,input().split())
if a==0:
    print(0)
    sys.exit()
else:
    s=int(n/(a+b))
    n=n%((a+b)*s)#余り
    if n<a:
        print(s*a+n)
    else:
        print(s*a+a)

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
x = []
def repeat_to_length(s, wanted):
    return (s * (wanted//len(s) + 1))[:wanted]
if a == 0:
    print("0")
else:
    r = repeat_to_length(("b"*a) + ("r"*b), n)
    print(r.count("b"))

Submission status: Runtime Error

Solution code:

row = ''

while len(row) <= N:
    row += '1' * A
    row += '0' * B

print(row[:N].count('1'))

Submission status: Runtime Error

Solution code:
i = input().split()
n = int(i[0])
blue = int(i[1])
red = int(i[2])
line = "b"*blue + "r"*red
line = line*(n/(blue+red))
line = line[0:n]
line = line.replace("r", "")
print(len(line))

Submission status: Runtime Error

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

i = 0
l = [0]*N
while i < N:
  for a in range(A):
    if i >= N : break
    l[i] = 'b'
    i += 1
    
    
  for b in range(B):
    if i >= N : break
    l[i] = 'r'
    i+= 1
    
print(l.count('b'))

Submission status: Runtime Error

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

    ans = 0

    b = 'b'*A
    r = 'r'*B
    br = b + r

    if(N > 0 and A >= 0 and B >= 0):
        #result = br * N
        if(N < A+B):
            count = N // (A+B)
        else:
            count = A+B
        result = br * count

        print(result)
        for i in range(N):
            if(result[i] == 'b'):
                ans+=1

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
s = list(input())
n = int(input())
p = []
for i in range(n):
  i =(input().split())
  if i[0] == '1':
    s = s[::-1]
  elif i[0] =='2':
    if i[1] == '1':
      s.insert(0,i[2])
    else:
      s.append(i[2])
#  count +=1      
      
#print(s)      
      
s = ''.join(s)
print(s)

Submission status: Runtime Error

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

list_a="a"*a
list_b="b"*b
a_l=int(n/(a+b))
b_l=n%(a+b)
if b_l > a : b_l =a
print(a_l*a+b_l)

Submission status: Runtime Error

Solution code:
a8, a10 = input().split(' ')
a8 = int(a8)
a10 = int(a10)
 
value1 = int(a8 / 0.08)
value2 = int(a10 / 0.1)

if int(value1 * 0.1) == a10:
  if value1 > value2:
    print(value1)
  else:
    print(value2)
elif int(value2 * 0.08 == a8):
  if value1 > value2:
    print(value1)
  else:
    print(value2)
else:
  print(-1)

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
s = 'b' * a + 'r' * b
sl = 0
str = ''
while sl < n:
  str += s
  sl = len(str)
print(str[:n].count('b'))

Submission status: Runtime Error

Solution code:
#B
import sys
n,a,b=map(int,input().split())
if a==0:
    print(0)
    sys.exit()
aa=0
s=n//(a+b)
n=n%((a+b)*s)#余り
if n<a:
    print(s*a+n)
else:
    print(s*a+a)

Submission status: Runtime Error

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

Line = ("b"*A+"r"*B)
Cnt = 0
while Cnt < N/(A+B):
	Line += Line
	Cnt += 1

print(Line[:N].count("b"))

Submission status: Runtime Error

Solution code:
i = input().split()
n = int(i[0])
blue = int(i[1])
red = int(i[2])
line = "b"*blue + "r"*red
line = line*1000
line = line[0:n]
line = line.replace("r", "")
print(len(line))

Submission status: Runtime Error

Solution code:
#B
import sys
n,a,b=map(int,input().split())
if a==0:
    print(-1)
    sys.exit()
aa=0
s=n//(a+b)
n=n%((a+b)*s)#余り
if n<a:
    print(s*a+n)
else:
    print(s*a+a)

Submission status: Runtime Error

Solution code:
n,a,b = input().split()
s = ''
if (a!='0'):
    s += 'b'*int(a) + 'r'*int(b)
if (len(s)<int(n) and int(a)!=0):
    s += 'b'
print(s.count('b') if a!='0' else 0)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

while len(a) != N:
    a.append("b" * A)
    a.append("a" * B)

a = "".join(a)

b = a[0: N]

c = b.count("b")
print(c)

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S ;
    int Q;
    string query1,query;
    cin>>S;
    cin>>Q;
    for(int i = 1; i <= Q;i++){
        getline(cin, query1);
        query = query1;
        if(query[0]=='1'){
            reverse(S.begin(), S.end()); 
        }else{
            if(query[2]=='1'){
                S = query[4] + S;
            }else
            {
                S = S + query[4];
            }
            
        }
    }
    cout<<S<<endl;
	return 0;
}

Submission status: Runtime Error

Solution code:
N,b,r = map(int,input().split())
if (b == 0 ){
	print(0)
}else {
	shou = N / (b +r)
	amari = N % (b + r)
	print(shou*b + amari)
}

Submission status: Runtime Error

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

Line = ("b"*A+"r"*B)
Cnt = 0
while Cnt < N:
	Line += Line
	Cnt += (A + B)

print(Line[:N].count("b"))

Submission status: Runtime Error

Solution code:
i = input().split()
n = int(i[0])
blue = int(i[1])
red = int(i[2])
line = ""
line = line + ("b"*blue + "r"*red)*10**100
line = line[0:n]
line = line.replace("r", "")
print(len(line))

Submission status: Runtime Error

Solution code:
n,a,b = input().split()
s = ''
if (a!='0'):
    s += 'b'*int(a) + 'r'*int(b)
while(len(s)<int(n) and int(a)!=0):
    s += 'b'
print(s.count('b') if a!='0' else 0)

Submission status: Runtime Error

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

Line = ("b"*A+"r"*B)
Cnt = 0
while Cnt < N:
	Line += Line
	Cnt += (A + B)

print(One_line[:N].count("b"))

Submission status: Runtime Error

Solution code:
i = input().split()
n = int(i[0])
blue = int(i[1])
red = int(i[2])
line = ""
while len(line) < n:
  line = line + "b"*blue + "r"*red
line = line[0:n]
line = line.replace("r", "")
print(len(line))

Submission status: Runtime Error

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

list_a="a"*a
list_b="b"*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(ans)

Submission status: Runtime Error

Solution code:
n, a, b = list(map(int, input().split()))
result = 0
if a + b != 0:
  roop = n // (a +b)
  extra = n - roop*(a+b)
  result = a*roop
  cycle = [1]*a +  [0]*b
  if extra != 0:
   result += sum(cycle[:extra]) 
print(result)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(20000)

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


def solve(acc, ans, a, b, next):
    if a == 0:
        return ans
    else:
        rem = acc - (a if next == 'a' else b)
        if rem <= 0:
            return ans + (a + rem if next == 'a' else 0)
        else:
            return solve(rem, ans + (a if next == 'a' else 0), a, b, ('b' if next == 'a' else 'a'))


print(solve(n, 0, a, b, 'a'))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
r=1
S=set()
while r<= 10**100:
	S='b'*A + str(S) +'r'*B
	if len(S)>10**18:
		S = S[1,10**18]
	r=r+1
print(S[1,N],count('b'))

Submission status: Runtime Error

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

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

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



c = n % (a +b)
if n % (a +b) < a:
    print((a * (n//(a+b))) + (n %(a+b)))
    exit()
else:
    print((a * (n//(a+b))) + a)
    eixt()

Submission status: Runtime Error

Solution code:
n, a, b = list(map(int, input().split()))
result = 0
if a + b != 0:
  roop = n // (a +b)
  extra = n - roop*(a+b)
  result = a*roop
  cycle = [1]*a +  [0]*b
  result += sum(cycle[:extra]) 
print(result)

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
One_line = ""
Line = ("b"*A+"r"*B)
Cnt = 0
while Cnt < N:
	One_line += Line
	Cnt += (A + B)

print(One_line[:N].count("b"))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
ans = []
for i in range(a):
  fa = []
  fa.append('b')
for j in range(b):
  fb = []
  fb.append('r')
for i in range(10000):
  ans.extend(fa)
  ans.extend(fb)
  if len(ans) >= n:
    break
hints = ans[0:n]
print(hints.count('b'))

Submission status: Runtime Error

Solution code:
n,a,b = input().split()
s = ''
if (a!='0'):
    s += 'b'*int(a) + 'r'*int(b)
else:
    print(0)
if(len(s)<int(n) and int(a)!=0):
    s += 'b'

print(s.count('b'))

Submission status: Runtime Error

Solution code:
8 3 4

Submission status: Runtime Error

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

list_a="a"*a
list_b="b"*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(ans)

Submission status: Runtime Error

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


def solve(acc, ans, a, b, next):
    if a == 0:
        return ans
    else:
        rem = acc - (a if next == 'a' else b)
        if rem <= 0:
            return ans + (a + rem if next == 'a' else 0)
        else:
            return solve(rem, ans + (a if next == 'a' else 0), a, b, ('b' if next == 'a' else 'a'))


print(solve(n, 0, a, b, 'a'))

Submission status: Runtime Error

Solution code:

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

if A==0 and B==0:
    print('0')

else:

    list_ab = []
    list_b = ['b']*A
    list_ab+=(list_b)
    list_a = ['a']*B
    list_ab+=list_a

    count = (N//(A+B))+1
    str = list_ab*count

    str = str[:N]
    print(str)
    print(str.count('b'))

Submission status: Runtime Error

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

c = n % (a +b)
if n % (a +b) < a:
    print((a * (n//(a+b))) + (n %(a+b)))
    exit()
else:
    print((a * (n//(a+b))) + a)
    eixt()

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
#define int long long int
using namespace std;
const int N = 1e5+50;

int32_t main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("atcoder.txt", "r", stdin);
	int tc = 1;
	for(int T=1; T<=tc; T++){
		int n, a, b; cin>>n>>a>>b;
		int rem = n%(a+b);
		int ans = rem%a;
		cout<<ans+a*(n/(a+b))<<"\n";
	}
	return 0;
}

Submission status: Runtime Error

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


x = N // (A + B)
y = N % (A + B)
z = 0

length = ('b' * A) + ('a' * B)

if y > 0:
    z = length[:y].count('b')

ans = x * A + z
print(int(ans))

Submission status: Runtime Error

Solution code:
N=int(input())
A=int(input())
B=int(input())
ball = 0
ball_b = 0
ball_r = 0

while ball < N-A-B:
    for i in range(A):
        ball+=1
        ball_b+=1
    for j in range(B):
        ball+=1
        ball_r+=1
x = min(N-ball,A)
print(ball_b+x)

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
if (0<A+B<=10**18)and(0<N<=10**18)and(A>=0)and(B>=0):
    queue="a"*A+"b"*B
    while len(queue)<N:
        queue+="a"*A+"b"*B
    number=queue.count("a",0,N)
    print(number)
else:
    None

Submission status: Runtime Error

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

c = n % (a +b)
if n % (a +b) > a:
    print((a * (n//(a+b))) + (n %(a+b)))
    exit()
else:
    print((a * (n//(a+b))) + a)
    eixt()

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
blue='c'*a
red='r'*b
s = str(blue+red)*(100*1000)
ss=s[:n]
print(ss.count('r'))

Submission status: Runtime Error

Solution code:
#include <stdio.h>
int main(void) {
  int n, a, b, x = 0, y, i;
  scanf("%d %d %d", &n, &a, &b);
  for (y = 0; y < n;) {
    for (i = 0; i < a; i++) {
      if (y == n) break;
      x++;
      y++;
    }
    for (i = 0; i < b; i++) {
      if (y == n) break;
      y++;
    }
  }
  printf("%d\n", x);
  return 0;
}

Submission status: Runtime Error

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

    ans = 0

    if(isinstance(N, int) and isinstance(A, int) and isinstance(B, int)):

        b = 'b'*A
        r = 'r'*B
        br = b + r

        if(N > 0 and A >= 0 and B >= 0):
            result = br * N

            if(len(result) > N):
                for i in range(N):
                    if(result[i] == 'b'):
                        ans+=1
            else:
                for i in range(len(result)):
                    if(result[i] == 'b'):
                        ans+=1                    

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:

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

row = []

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

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

if A+B == N:
    print(A)
    exit()


for _ in range(N):
    row += [1]*A
    row += [0]*B

print( row[:N].count(1) )

Submission status: Runtime Error

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 and b == 0 || a == 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: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, a, b = list(map(int, input().split()))
result = 0
if a + b != 0:
  roop = n // (a +b)
  extra = n - roop*(a+b)
  result = a*roop
  cycle = [1]*a +  [0]*b
  if extra != 0:
    result += sum(cycle[:extra]) 
print(result)

Submission status: Runtime Error

Solution code:
N,A,B=input().split()
N=int(N)
A=int(A)
B=int(B)
C=A+B
if (0<C<=10**18)and(0<N<=10**18)and(A>=0)and(B>=0):
    queue="a"*A+"b"*B
    while len(queue)<N:
        queue+="a"*A+"b"*B
    number=queue.count("a",0,N)
    print(number)
else:
    None

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(200000)

def main(N: int , A: int , B: int):
    r = "b" * A
    r += "r" * B
    for i in range(10*100):
        r += r
        if N <= len(r):
            sub = r[:N]
            return sub.count("b")

if __name__ == "__main__":
    s = input().split()
    N = int(s[0])
    A = int(s[1])
    B = int(s[2])
    print(main(N, A, B))

Submission status: Runtime Error

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

    ans = 0
    if(isinstance(N, int) and isinstance(A, int) and isinstance(B, int)):

        b = 'b'*A
        r = 'r'*B
        br = b + r

        if(N > 0 and A >= 0 and B >= 0):
            result = br * N

            if(len(result) > 0):
                for i in range(N):
                    if(result[i] == 'b'):
                        ans+=1

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:

N, A,B = map(int, input().split())
str = []
if A==0 and B==0:
    print('0')

else:
    
    list_ab = []
    list_b = ['b']*A
    list_ab+=(list_b)
    list_a = ['a']*B
    list_ab+=list_a

    count = (N//(A+B))+1
    str = list_ab*count

    str = str[:N]
    print(str.count('b'))

Submission status: Runtime Error

Solution code:
N=int(input())
A=int(input())
B=int(input())
ans=0
ans = ans + N/(A+B)
if N%(A+B)<=A:
  ans = ans + (N%(A+B))
else:
  ans = ans + A
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

    if(isinstance(N, int) and isinstance(A, int) and isinstance(B, int)):

        b = 'b'*A
        r = 'r'*B
        br = b + r

        ans = 0

        if(N > 0 and A >= 0 and B >= 0):
            result = br * N

            if(len(result) > 0):
                for i in range(N):
                    if(result[i] == 'b'):
                        ans+=1

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
One_line = ""
Line = ("r"*B+"b"*A)
Cnt = 0
while Cnt < N:
	One_line += Line
	Cnt += (A + B)

print(One_line[:N].count("b"))

Submission status: Runtime Error

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)
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)
提出情報
提出日時	2020-03-07 21:19:42
問題

Submission status: Runtime Error

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: Runtime Error

Solution code:
n, a, b = list(map(int, input().split()))
roop = n // (a +b)
extra = n - roop*(a+b)
result = a*roop
cycle = [1]*a +  [0]*b
if extra != 0:
  result += sum(cycle[:extra]) 
print(result)

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
s = [1] * a + [2] * b
str = []
while len(str) < n:
  str.extend(s)
del str[n:-1]
print(str.count(1))

Submission status: Runtime Error

Solution code:
n,a,b=[int(i) for i in input().split()]
s=''
s+='b'*a
s+='r'*b
s*=n//(a+b)+1
print(s[:n].count('b'))

Submission status: Runtime Error

Solution code:
n, a, b = list(map(int, input().split()))
roop = n // (a +b)
extra = n - roop*(a+b)
print(extra)
result = a*roop
cycle = [1]*a +  [0]*b
if extra != 0:
  result += sum(cycle[:extra]) 
print(result)

Submission status: Runtime Error

Solution code:

def main(N: int , A: int , B: int):
    r = "b" * A
    r += "r" * B
    for i in range(10*18):
        r += r
        if N <= len(r):
            sub = r[:N]
            return sub.count("b")

if __name__ == "__main__":
    s = input().split()
    N = int(s[0])
    A = int(s[1])
    B = int(s[2])
    print(main(N, A, B))

Submission status: Runtime Error

Solution code:
n = list(map(int, input().split()))
l = []

for i in range(n[0] * n[1] * n[2]):
    for j in range(n[1]):
        l.append('blue')
    for k in range(n[2]):
        l.append('red')

blue = 0
red = 0

for i in range(n[0]):
    if l[i] == 'blue':
        blue = blue + 1


print(blue)

Submission status: Runtime Error

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

cnt_a = cnt_b = 0

for i in range(10*100):
    if cnt_a + cnt_b + A >= N: 
        # N - cnt_a - cnt_b はみ出た分
        ans = cnt_a + N - cnt_a - cnt_b

    else:
        cnt_a += A
        cnt_b += B

print(ans)

Submission status: Runtime Error

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

    b = 'b'*A
    r = 'r'*B
    br = b + r

    ans = 0

    if(N > 0 and A >= 0 and B >= 0):
        result = br * N

        if(len(result) > 0):
            for i in range(N):
                if(result[i] == 'b'):
                    ans+=1

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def solve():
    N, A, B = map(int, input().split())
    if A + B == 0:
        print(0)
        exit(0)

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

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

if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:

N, A,B = map(int, input().split())
str = []
if A==0 and B==0:
    print('0')

else:
    from math import floor
    list_ab = []
    list_b = ['b']*A
    list_ab+=(list_b)
    list_a = ['a']*B
    list_ab+=list_a

    count = (floor(N/(A+B))+1)
    str = list_ab*count




    str = str[:N]
    print(str.count('b'))

Submission status: Runtime Error

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

row = ""

if N[1] == 0:
    print(0)
else:
    remain = int(N[0]//(N[1]+N[2]))
    remain_2 = N[0] - N[1]*remain - N[2]*remain
    row += "b"*N[1]*remain+"a"*N[2]*remain+"b"*remain_2
    print(row.count("b"))

Submission status: Runtime Error

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

    b = 'b'*A
    r = 'r'*B
    br = b + r

    ans = 0

    if(N > 0 and A > 0 and B > 0):
        result = br * N

        for i in range(N):
            if(result[i] == 'b'):
                ans+=1

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def count(b, total, N):
    remain = N%total
    if remain < b:
        return remain
    else:
        return b

data = input()
N, b, r = [int(i) for i in data.split()]
 
ball = int(N/total) * b + count(b, b+r, N)
print(ball)

Submission status: Runtime Error

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

    b = 'b'*A
    r = 'r'*B
    br = b + r

    ans = 0

    if(N > 0 and A >= 0 and B >= 0):
        result = br * N

        for i in range(N):
            if(result[i] == 'b'):
                ans+=1

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split(' '))
 
row = ''
for i in range(int(N/(A+B)) +1):
    row+='b' * A
    row+= 'r' * B
print(list(row[:N]).count('b'))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().rstrip().split())
if A + B == 0:
    ret = 0
else:
    ret = int(N / (A + B)) * A + ('b'*A + 'r'*B)[:(N % (A + B))].count('b')
print(ret)

Submission status: Runtime Error

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

    b = 'b'*A
    r = 'r'*B
    br = b + r

    ans = 0

    if(N > 0 and A >= 0 and B >= 0:
        result = br * N

        for i in range(N):
            if(result[i] == 'b'):
                ans+=1

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
s = "a" * a + "b" * b
S = s * (int(n / (a + b)) + 1)
print(S[:n].count("a"))

Submission status: Runtime Error

Solution code:
nums = [int(e) for e in input().split()]
n = nums[0]
a = nums[1]
b = nums[2]
22 3 4
bbb4444bbb4444bbb4444b
sum = a + b
iter = n // sum
amari = n % sum
if amari >= b:
	print(iter * a + (b))
else:
  print(iter * a + (amari))

Submission status: Runtime Error

Solution code:
N=int(input())
A=int(input())
B=int(input())
ball = 0
ball_b = 0
ball_r = 0

while ball < N-A-B+1:
    for i in range(A):
        ball+=1
        ball_b+=1
    for j in range(B):
        ball+=1
        ball_r+=1
x = min(N-ball,A)
print(ball_b+x)

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
s=''
s+='b'*a
s+='r'*b
s*=n//(a+b)+1
print(s[:n].count('b'))

Submission status: Runtime Error

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

    b = 'b'*A
    r = 'r'*B
    br = b + r

    ans = 0

    if(N > 0 and and N<= pow(10,19) and A >= 0 and B >= 0 and A+B <= pow(10,18)):
        count = N // (A+B) + 1
        result = br * N

        for i in range(N):
            if(result[i] == 'b'):
                ans+=1

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:

def main(N: int , A: int , B: int):
    r = "b" * A
    r += "r" * B
    for i in range(10*100):
        r += r
        if N <= len(r):
            if N == len(r):
                return r.count("b")
            sub = r[:N]
            return sub.count("b")

if __name__ == "__main__":
    s = input().split()
    N = int(s[0])
    A = int(s[1])
    B = int(s[2])
    print(main(N, A, B))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
l = ""
cnt = 0
n1 = "b" * A
n2 = "r" * B
for i in range(N + 2):
    l += n1 + n2
   
for j in l[0 : N]:
    if j == "b":
        cnt += 1
          
print(cnt)

Submission status: Runtime Error

Solution code:
n=list(map(int,input().split()))
list=[]
liste=""
a=n[1]
b=n[2]
A="A"*a
B="B"*b
if n[1]==0:
    print(0)
elif n[2]==0:
    print(n[0])
else:
    while len(liste)<=n[0]:
        
        list.append(A)
        list.append(B)
      
        for x in list:
            liste+=x
    listo=liste[0:n[0]]
    print(listo.count("A"))

Submission status: Runtime Error

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

row = ""

if N[1] == 0:
    print(0)
else:
    remain = int(N[0]//(N[1]+N[2]))
    remain_2 = N[0] - N[1]*remain - N[2]*remain
    row += "b"*N[1]*remain+"a"*N[2]*remain+"b"*remain_2
    print(row.count("b"))

Submission status: Runtime Error

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

    b = 'b'*A
    r = 'r'*B
    br = b + r

    ans = 0

    if(N > 0 and A >= 0 and B >= 0):
        count = N // (A+B) + 1
        result = br * N

        for i in range(N):
            if(result[i] == 'b'):
                ans+=1

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
qaws = ""
while(N > len(qaws)):
  qaws += ("B"*A)
  qaws += ("R"*B)
print(qaws[:N].count("B"))

Submission status: Runtime Error

Solution code:

N, A,B = map(int, input().split())
str = []
from math import floor
list_ab = []
list_b = ['b']*A
list_ab+=(list_b)
list_a = ['a']*B
list_ab+=list_a

count = (floor(N/(A+B))+1)
str = list_ab*count




str = str[:N]
print(str.count('b'))

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
qaws = ""
while(N > len(qaws)):
  qaws += ("B"*A)
  qaws += ("R"*B)
print(qaws[:N].count("B")

Submission status: Runtime Error

Solution code:
def count(b, total, N):
    remain = N%total
    if remain < b:
        return remain
    else:
		return b

data = input()
N, b, r = [int(i) for i in data.split()]

ball = int(N/total) * b + count(b, b+r, N)
print(ball)

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
C=A+B
if (0<C<10**18)and(0<N<=10**18)and(A>=0)and(B>=0):
    queue=("a"*A+"b"*B)*N
    number=queue.count("a",0,N)
    print(number)
else:
  None