Problem:


Score : 200 points

Problem Statement

Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:

Red boxes, each containing R red balls

Green boxes, each containing G green balls

Blue boxes, each containing B blue balls

Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes.
How many triples of non-negative integers (r,g,b) achieve this?

Constraints

All values in input are integers.

1 \leq R,G,B,N \leq 3000

Input

Input is given from Standard Input in the following format:

R G B N

Output

Print the answer.

Sample Input 1

1 2 3 4

Sample Output 1

4

Four triples achieve the objective, as follows:

(4,0,0)

(2,1,0)

(1,0,1)

(0,2,0)

Sample Input 2

13 1 4 3000

Sample Output 2

87058



Sample input:
1 2 3 4


Sample output:
4

Submission status: Time Limit Exceeded

Solution code:
import math
r,g,b,n = map(int, input().split())
count = 0
r,g,b = sorted((r,g,b))
for x in range( math.ceil((n / r)) + 1):
    for y in range( math.ceil( (n - (r*x) ) / g) + 1):
        for z in range(math.ceil((n - (r * x) - (g * y)) + 1)):
            if (n - (r * x) - (g * y) - (b * z) ) == 0:
                count = count + 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N= map(int, input().split())
answer=0

for r in range(3001):
    for g in range(3001):
        for b in range(3001):
            if R * r + G * g + B * b == N:
                answer += 1
                break
            elif R * r + G * g + B * b > N:
                break
        if R * r + G * g> N:
            break
    if R*r>N:
        break
print(answer)

Submission status: Time Limit Exceeded

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

num_r=n//r+1
num_g=n//g+1

for i in range(num_r):
    for k in range((n-i*r)//g+1):
        if n-r*i-g*k>=0 and (n-r*i-g*k)%b==0:
            ctr+=1
print(ctr)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int, input().split())
sum = 0
for i in range(int(N / R) + 1):
  for j in range(int((N - (i * R)) / G) + 1):
    for k in range(int((N - (i * R) - (j * G)) / B) + 1):
      ans = i * R + j * G + k * B
      if (ans == N):
        sum += 1
print(sum)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int, input().split())
count = 0

for r in range(int(N/R)+1):
  for g in range(int(N/G)+1):
    b = (N-(r*R+g*G))
    if b%B==0 and b/B>=0: count+=1
    

print(count)

Submission status: Time Limit Exceeded

Solution code:
import itertools
R,G,B,N = map(int, input().split())
count = 0
Rc = [i * R for i in range(0, int(N / R) +1)]
Gc = [i * G for i in range(0, int(N / G) +1)]
Bc = [i * B for i in range(0, int(N / B) +1)]
#print(Rc)
#print(Gc)
#print(Bc)
Combi = list(itertools.product(Rc, Gc, Bc))
print(sum([True for i in Combi if sum(i) == N]))

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
ans = 0
for r in range(N+1):
  if r*R>N:
    break
  for g in range(N+1):
    if r*R+g*G>N:
      break
    if (N-r*R-g*G)%B==0:
      ans+=1
print(ans)

Submission status: Time Limit Exceeded

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

c = 0
for r in range(N + 1):
	if N < r * R:
		break
	for g in range(N + 1):
		if N < r * R + g * G:
			break
		x = (N - r * R - g * G)
		if not x % B and (0 <= (x // B)):
			#print(r, g, b)
			c += 1
print(c)

Submission status: Time Limit Exceeded

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

array = [r,g,b]
sort_array = sorted(array)

cnt = 0
n1 = sort_array[2]
n2 = sort_array[1]
n3 = sort_array[0]
r = n1
g = n2
b = n3
for rn in range(0,n + 1):
  if (r * rn) > n:
    continue
  for gn in range(0,n + 1):
    if (r * rn + g * gn) > n:
      continue
    if (n - (r * rn + g * gn)) % b == 0:
      cnt = cnt+1

print(cnt)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(N//R + 1):
    for j in range(N//G + 1):
        if (i*R + j*G) == N:
            ans += 1
        if (i*R + j*G) < N and (N - (i*R + j*G)) % B == 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

l = [r, g, b]
l.sort(reverse=True)
for i in range(n+1):
    if l[0]*i > n:
        break
    for j in range(n+1):
        if l[0]*i + l[1]*j > n:
            break
        elif (n-(l[0]*i + l[1]*j)) % l[2] == 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

sum = 0
count = 0

len_R = N // R + 1
len_G = N // G + 1
len_B = N // B + 1

for ix in range(N // R + 2):
    for iy in range(N // G + 2):
        sum = N - (R * ix + G * iy)
        if sum >= 0 and sum % B == 0:
            count += 1
        if R * ix + G + iy > N:
            break
    if R * ix > N:
        break

print(count)

Submission status: Time Limit Exceeded

Solution code:
r, g, b, n = [int(i) for i in input().split(" ")]
c = 0
for i in range(0, n // r + 1):
    for j in range(0, n // g + 1):
        t = n - i * r - j * g
        if t >= 0 and t % b == 0:
            c += 1
print(c)

Submission status: Time Limit Exceeded

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


cnt = 0
ball = 0
a = sorted([R,G,B])
for r in range(N//a[0]+1):
    ball = r*a[0]
    for b in range((N-ball)//a[1]+1):
        if N-ball >= 0 and (N-ball-b*a[1])%a[2] == 0:
            cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = (int(i) for i in input().split())
C = 0

for r in range((N//R) + 1):
    for g in range((N//G) + 1):
        for b in range((N//B) + 1):
            if N == ((R * r) + (G * g) + (B * b)):
                C += 1
print(C)

Submission status: Time Limit Exceeded

Solution code:
import math
r,g,b,n = map(int, input().split())
count = 0
for x in range( math.ceil((n / r)) + 1):
    for y in range( math.ceil( (n - (r*x) ) / g) + 1):
        for z in range(math.ceil((n - (r * x) - (g * y)) + 1)):
            if (n - (r * x) - (g * y) - (b * z) ) == 0:
                count = count + 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
rn,gn,bn,n=map(int,input().split())
print(sum(n-rn*r-gn*g >=0 and (n-rn*r-gn*g)%bn==0 for r in range(1+n//rn) for g in range(1+n//gn)))

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(N//R+1):
    if i*R > N:
        break
    for j in range(N//G+1):
        if i*R + j*G > N:
            break
        for k in range(N//B+1):
            if i*R + j*G + k*B > N:
                break
            elif i*R + j*G + k*B == N:
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,n=map(int,input().split())
ans=0

for r in range((n+1)//R+1):
    for g in range((n-r*R+1)//G+1):
        b=n-(r*R+g*G)
        if b%B==0:
            if 0<=b/B<=n:
                ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
counter = 0


min_num = min([R,G,B])
# print(min_num)
a = N / min_num

for i in range(int(a)+1):

    if N < B*i:
        break 
    
    else:
        for s in range(int(a)+1):
            tmp = N - B*i - G*s
            tmp = tmp / R

            if tmp < 0:
                break

            elif tmp - int(tmp) == 0:
                counter += 1
        
print(counter)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
cnt = 0
for r in range(N//R+1):
	for g in range(N//G+1):
		if (N-R*r-G*g)%B==0 and (N-R*r-G*g)//B>=0:
			cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

targets = [N - R * i for i in range(int(N / R) + 1)]
score = 0
for g in range(3001):
    for b in range(3001):
        if g + b > 3000:
            break
        if (g * G + b * B) in targets:
            score += 1

print(score)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int, input().split())
cn = 0
for r in range(N+1):
    if R*r > N:
        continue
    else:
        g_max = N - R*r + 1
    for g in range(g_max):
        if R*r + G*g > N:
            continue
        elif (N - R*r -G*g)%B == 0:
            cn += 1
print(cn)

Submission status: Time Limit Exceeded

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

rmax = N//R
gmax = N//G
bmax = N//B

cnt = 0

for i in range(rmax+1):
    for j in range(gmax+1):
        if R*i + G*j > N:
            continue
        if ((N-R*i-G*j)%B == 0) and ((N-R*i-G*j)//B <= bmax):
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math

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

count = 0
max_r = math.floor(N/R)
max_g = math.floor(N/G)
max_b = math.floor(N/B)


for i in range(max_r + 1):
    if (i * R) > N:
        break
    for j in range(max_g + 1):
        #print(N - (i * R + j * G ))
        if (i * R + j * G) > N:
            break
        if (N - (i * R + j * G)) % B == 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:

r,g,b,n = map(int,input().split())

ans = 0
rmax = n//r
gmax = n//g
for i in range(rmax+1):
    for j in range(gmax+1):
        rest = n-r*i-g*j
        flag = rest>=0 and rest%b==0
        if flag: ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N=map(int, input().split())
ans=0
for i in range(N//R+1):
    for j in range((N-i*R)//G+1):
        for k in range((N-i*R-j*G)//B+1):
            if (i*R+j*G+k*B)==N:
                ans +=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
count = 0

for r in range(N + 1):
    for g in range(N + 1 - r):
        for b in range(N + 1 - r - g):
            if r * R  + g * G + b * B == N:
                count = count + 1

print(count)

Submission status: Time Limit Exceeded

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

sum = 0
count = 0

len_R = N // R + 1
len_G = N // G + 1
len_B = N // B + 1

for ix in range(N // R + 2):
    for iy in range(N // G + 2):
        sum = N - (R * ix + G * iy)
        if sum % B == 0:
            if sum / B >= 0:
                count += 1
        sum = R * ix + G + iy
        if sum > N:
            break
    sum = R * ix
    if sum > N:
        break

print(count)

Submission status: Time Limit Exceeded

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

org_list = [R, G, B]
org_list.sort()
first_num = org_list[2]
second_num = org_list[1]
third_num = org_list[0]

count = 0

for i in range(N // first_num + 1):
  if i*first_num > N:
    break
  for j in range(N // second_num + 1):
    if i*first_num + j*second_num > N:
      break
    if (N - i*first_num - j*second_num) % third_num == 0:
      count += 1
 
print(count)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
ans = 0
for i in range(N//R +1):
    for j in range(N//G +1):
        if (N- i*R - j*G)%B == 0 and (N- i*R - j*G) >= 0 :
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
ans = 0
for r in range(1 + N//R):
    for g in range(1 + N//G):
        nokori = N - R * r - G * g
        if nokori >= 0 and nokori % B == 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 26 17:52:43 2019

@author: nakamuratakayuki
"""

R,G,B,N = tuple(map(int,input().split()))
c = 0
rmax = N//R

for i in range(rmax+1):
    gmax = (N-R*i)//G
    for j in range(gmax+1):
        bmax = (N-R*i-G*j)//B
        for k in range(bmax+1):
            if R*i+G*j+B*k == N:
                c += 1

print(c)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
ans=0
for i in range(n//b+1):
    for j in range(n//g+1):
        for k in range(n//r+1):
            if r*k+g*j+b*i==n:
                ans=ans+1
            elif r*k+g*j+b*i>n:
                break
print(ans)

Submission status: Time Limit Exceeded

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

R, G, B, N = map(int, input().split())

counter = 0
for r in range(int(N/R) + 1):
    for g in range(int(N/G) + 1):
        if R*r + G*g > N:
            break
        if (N - R*r - G*g) % B == 0:
            counter += 1

print(counter)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split(' '))
num = 0
for i in range(int(N//R)+1):
  for j in range(int(N//G)+1):
    A = N-R*i-G*j
    if A >= 0  and A % B == 0:
      num += 1
print(num)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int, input().split())
count = 0

for r in [i*R for i in range(int(N/R)+1)]:
  for g in [i*G for i in range(int(N/G)+1)]:
    b = (N-(r+g))/B
    if (N-(r+g))%B==0 and b>=0: count+=1
    

print(count)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int, input().split())
ans = 0
for i in range(n // r + 1):
        for j in range((n - i * r)// g + 1):
                if ( n -  ( i * r  +  j * g )) % b == 0 and i * r + j * g <= n:
                        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math

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

count = 0
max_r = math.floor(N/R)
max_g = math.floor(N/G)
max_b = math.floor(N/B)


for i in range(max_r + 1):
    for j in range(max_g + 1):
        #print(N - (i * R + j * G ))
        if (i * R + j * G) > N:
            break
        if (N - (i * R + j * G)) % B == 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n =map(int,input().split())
count =0
for i in range(4000):
    if r * i <= n:
        for j in range(4000):
            if (r * i + g * j) <= n:
                for k in range(4000):
                    if r*i+g*j+b*k == n:
                        count += 1
                    elif r*i+g*j+b*k > n:
                        break
            else:
                break
    else: 
        break

print(count)

Submission status: Time Limit Exceeded

Solution code:
import itertools
R,G,B,N = map(int, input().split())
count = 0
Rc = [i * R for i in range(0, N+1) if i * R <= N]
Gc = [i * G for i in range(0, N+1) if i * G <=  N]
Bc = [i * B for i in range(0, N+1) if i * B <=  N]
#print(Rc)
#print(Gc)
#print(Bc)
Combi = list(itertools.product(Rc, Gc, Bc))
print(sum([True for i in Combi if sum(i) == N]))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

import sys
input = sys.stdin.readline

# N = int(input())
# L = [int(x) for x in input().split()]
R, G, B, N = map(int, input().split())
# S = input()

ans = 0

for r in range(N // R + 1) :
    if R * r > N :
        break

    for g in range(N // G + 1) :
        if R * r + G * g > N :
            break

        if (N - (R * r + G * g)) % B == 0 :
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
ans = 0
for r in range(N//R+1):
  for g in range((N-R*r)//G+1):
    if r*R+g*G>N:
      continue
    if (N-r*R-g*G)%B==0:
      ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    R,B,G,N = list(map(int,input().split(' ')))
    cnt = 0
    for i in range(N//R+1):
        for j in range(N//G+1):
            if R*i+G*j > N:
              break
            if (N-(R*i+G*j))//B == (N-(R*i+G*j))/B and (N-(R*i+G*j))/B >=0:
                cnt +=1
    print(cnt)

if __name__ =='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
cnt = 0

for r in range(N // R + 1):
    for g in range(N // G + 1):
        if (N - r * R - g * G) % B == 0 and (N - r * R - g * G) >= 0:
            cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
nr=n//r
ng=n//g
nb=n//b
ans=0
lst=[b*k for k in range(nb+1)]
l=len(lst)
import bisect
for i in range(nr+1):
  for j in range(ng+1):
    res=n-i*r-j*g
    idx=bisect.bisect_left(lst,res)
    if idx<l and lst[idx]==res:
      ans+=1
        
print(ans)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
ans = 0
i, j = 0, 0
while R*i<=N:
    while R*i+G*j<=N:
        if (N-(R*i+G*j))%B == 0:
            ans += 1
        j += 1
    else:
        j = 0
    i += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
counter = 0


min_num = min([R,G,B])
a = N / min_num

for i in range(int(a)+1):
    for s in range(int(a)+1):
        tmp = N - B*i - G*s
        tmp = tmp / R

        if tmp < 0:
            break

        elif tmp - int(tmp) == 0:
            counter += 1
        
print(counter)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
R, G, B, N = map(int, input().split())
cnt = 0
for i in range(int(N/R)+1):
    r = i*R
    for j in range(int(N/G)+1):
        g = j*G
        b = N - g - r
        if b >= 0 and b % B == 0:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int,input().split())
count = 0
rr = n // r
gg = n // g
for i in range(rr+1):
  for j in range(gg+1):
    if n >= i*r + j*g and (n - (i*r + j*g)) %  b == 0:
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N=(int(i) for i in input().split())
import math
answer=0
for r in range(0,math.floor(N/R)+1):
    for g in range(math.floor(N/G)+1):
        if R*r+G*g>N:
            break
        if (N-R*r-G*g)%B==0:
            answer+=1

print(answer)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
rmax = N // R
gmax = N // G
cnt = 0
for r in range(rmax + 1):
  for g in range(gmax + 1):
    rest = N - R * r - G * g
    if rest >= 0 and rest % B == 0:
      cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = [int(n) for n in input().split()]

count = 0
for r in range(N//R + 1):
    for g in range((N-r*R)//G + 1):
        if (N - (R * r + G * g)) % B == 0:
            b = (N - (R * r + G * g)) / B
            if  0 <= b <=  N//B:
                count += 1

print(count)

Submission status: Time Limit Exceeded

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

result = 0

max_r = n // r

for i in range(max_r + 1):
    max_g = (n - i * r) // g + 1
    for j in range(max_g):
        max_b = (n - i * r - j * g) // b + 1
        if i * r + j * g > n:
                continue
        for k in range(max_b):
            if i * r + j * g + k * b == n:
                result += 1
print(result)

Submission status: Time Limit Exceeded

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

cnt = 0
NR = N//R
NG = N//G
for r in range(NR + 1):
  for g in range(NG + 1):
    NrRgG = N - (r*R + g*G)
    if NrRgG >= 0 and NrRgG % B == 0:
      cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int, input().split())
ans = 0
for i in range(n // r + 1):
        for j in range(n // g + 1):
                if ( n -  ( i * r  +  j * g )) % b == 0 and i * r + j * g <= n:
                        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

r,g,b,n = getList()
ans = 0
for i in range(n//r + 2):
    for j in range((n-r*i) // g + 2):
        if (n- r*i - g*j) % b == 0 and (r*i + g*j) <= n:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,n=map(int,input().split())
cnt=0
for x in range(n//R+1):
    for y in range((n-x*R)//G+1):
        if (n-x*R-y*G)%B==0 and (n-x*R-y*G)/B>=0:
            cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

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

i = 0
j = 0
cnt = 0

while i*R <= N:
    while i*R + j*G <= N:
        temp = N - i*R - j*G
        if temp % B == 0:
            cnt += 1
        j += 1
    j = 0
    i += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import sys
from fractions import gcd
from functools import reduce
from itertools import combinations

import numpy as np

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    R, G, B, N = il()
    ans = 0
    for r in range(N // R + 1):
        for g in range(N // G + 1):
            b = N - r * R - g * G
            b = b // B
            if b < 0:
                continue
            if r * R + g * G + b * B == N:
                ans += 1
    return ans


if __name__ == "__main__":
    print(solve())

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int,input().split())
count = 0
rr = n // r
gg = n // g
bb = n // b
for i in range(rr+1):
  for j in range(gg+1):
    if n >= i*r + j*g and (n - (i*r + j*g)) %  b == 0:
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int, input().split())
a = 0
for i in range(int(n/r)+1):
    if r*i>n:
        break
    for j in range(int(n/g)+1):
        if g*j>n:
            break
        for k in range(int(n/b)+1):
            if b*k>n:
                break
            if r*i+g*j+b*k==n:
                a = a+1
print(a)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int,input().split())
counter = 0
a = (n // r)+1
c = (n// g)+1

for i in range(a):
    for j in range(c):
        left = n - (r*i) - (g*j)
        if left >= 0 and   left % b == 0:
            counter += 1
            
print(counter)

Submission status: Time Limit Exceeded

Solution code:
import math
r,g,b,n = [int(u) for u in input().split(" ")]
i = 0
for ir in range(math.floor(n/r)+1):
  if ir*r>n:
    break
  for ig in range(math.floor(n/g)+1):
    if ig*g>n:
      break
    y = n- (ir*r+ig*g)
    if y>=0 and y%b==0:
      #print(ir,ig,y/b)
      i+=1
print(i)

Submission status: Time Limit Exceeded

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

res = 0

for i in range(N // R + 1):
    for j in range(N // G + 1):
        b = N - R * i - G * j
        if b >= 0 and b % B == 0:
            res += 1

print(res)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().strip().split())

B_list=[]
for i in range(N//B+1):
    B_list.append(N-i*B)

count = 0
for i in range(N // R + 1):
    for j in range(N // G + 1):
            if i * R + j * G in B_list:
                count += 1

print(count)

Submission status: Time Limit Exceeded

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

count = 0
for i in range(n+1):
    for j in range(n+1):
        k = (n - (r*i+j*g))//b
        if k < 0:
            continue
        if (r*i+g*j+b*k == n):
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
R, G, B, N= map(int, input().split())

A=[R,G,B]
A.sort()
A=np.array(A)

count=0

shou_max = N//A[2]
warukazu2 = np.arange(0, shou_max+1)
A3 = N-warukazu2*A[2]

for x in A3:
    shou_max = x//A[1]
    warukazu1 = np.arange(0, shou_max+1)
    A2 = x-warukazu1*A[1]
    
    for y in A2:
        if y%A[0]==0:
            count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
cnt=0
s=0
for i in range(n//r+1):
    for j in range(n//g+1):
        k=(n-(i*r+j*g))//b
        s=i*r+j*g+k*b
        if s==n and k>=0:
            cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
input = sys.stdin.readline
 
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
def main():
	R, G, B, N = map(int, input().split(" "))
	
	ans = 0
	for i in range(N+1):
		r = i * R
		for j in range(N+1):
			g = j * G
			if N - r - g < 0:
				continue
			if (N - r - g) % B != 0:
				continue
			k = (N - r - g) // B
			#print("{} {} {}".format(i, j, k))
			ans += 1
			

	print(ans)

	
	
if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int,input().split())
cnt = 0
for r in range(N//R + 1):
    for g in range(N//G + 1):
        x = N - R*r - G*g
        if x >= 0 and x % B == 0:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=[int(i) for i in input().split()]
ans=0
for i in range(n//r+1):
    for j in range((n-r*i)//g+1):
        if r*i+g*j>n:
            break
        elif (n-(r*i+g*j))%b==0:
            ans+=1
print(ans)

Submission status: Time Limit Exceeded

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

cnt = 0
for rn in range(0,n + 1):
  if (r * rn) > n:
    continue
  for gn in range(0,n + 1):
    if (r * rn + g * gn) > n:
      continue
    if (n - (r * rn + g * gn)) % b == 0:
      cnt = cnt+1

print(cnt)

Submission status: Time Limit Exceeded

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

def solve():
    R, G, B, N = list(map(int, input().split()))

    ans = 0
    for r in range(0, N+1):
        num1 = r*R
        if num1 > N: break

        for g in range(0, N+1):
            num2 = g*G
            if num1+num2 > N: break

            for b in range(0, N+1):
                num3 = b*B
                if num1+num2+num3 > N: break
                if num1+num2+num3 == N:
                    ans += 1

    print(ans)

if __name__ == "__main__":
    solve()

Submission status: Time Limit Exceeded

Solution code:
R,G,B,n=map(int,input().split())
ans=0

for r in range((n+1)//R+1):
    for g in range((n-r+1)//G+1):
        b=n-(r*R+g*G)
        if b%B==0:
            if 0<=b/B<=n:
                ans+=1
print(ans)

Submission status: Time Limit Exceeded

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

tmp = [i for i in range(n+1)]

count = 0
for i in tmp:
    if(i*r > n): break
    for j in tmp:
        if(i*r + j*g > n): break
        
        if(((n-i*r-j*g) // b == (n-i*r-j*g) / b)):
            count += 1

print(count)

Submission status: Time Limit Exceeded

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

ans = 0
for r in range(N+1):
    for g in range(N+1):
        blue = N - R*r - G*g
        if blue >= 0 and blue % B == 0:
            ans += 1


print(ans)

Submission status: Time Limit Exceeded

Solution code:
data = list(map(int, input().split()))
R = data[0]
G = data[1]
B = data[2]
N = data[3]

# R * a + G * b + B * c 

a = N // R + 1
b = N // G + 1
c = N // B + 1
res = 0

for Ri in range(a):
    if Ri * R > N:
        break
    for Gi in range(b):
        if Ri * R + Gi * G > N:
            break
        for Bi in range(c):
            if Ri * R + Gi * G + Bi * B > N:
                break
            if Ri * R + Gi * G + Bi * B == N:
                res = res + 1

print(res)

Submission status: Time Limit Exceeded

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

nr_max = n // r
ng_max = n // g
nb_max = n // b

count = 0
for i in range(0, nr_max + 1):
    tmp1 = r * i
    if tmp1 == n:
        count += 1
    if tmp1 >= n:
        break
    for j in range(0, ng_max + 1):
        tmp2 = g * j + tmp1
        if tmp2 == n:
            count += 1
        if tmp2 >= n:
            break
        for k in range(0, nb_max + 1):
            tmp2 += b
            if tmp2 == n:
                count += 1
            if tmp2 >= n:
                break
print(count)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
count=0
for ri in range(int(n/r)+1):
    for gi in range(int(n/g)+1):
        sumc=n-ri*r-gi*g
        if sumc<0:
            break
        if sumc%b==0 and sumc/b>=0:
            count+=1
print(count)

Submission status: Time Limit Exceeded

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

maxr=N//R
maxg=N//G
maxb=N//B

ans=0
flg=0
for i in range(maxr,-1,-1):
  for j in range(maxg,-1,-1):
    for k in range(maxb,-1,-1):
      if R*i+G*j+B*k==N:
        ans+=1
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
a=0
for i in range (0,n//r+1):
  t=n-r*i
  for j in range (0,n//g+1):
    k=t-j*g
    if k>=0:
      if k%b==0:
        a=a+1
print(a)

Submission status: Time Limit Exceeded

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

n = 1000
count = 0
for i in range(N // R + 1):
  if i*R > N:
    break
  for j in range(N // G + 1):
    if i*R + j*G > N:
      break
    if (N - i*R - j*G) % B == 0:
      count += 1
 
print(count)

Submission status: Time Limit Exceeded

Solution code:
def main():
    r,g,b,n = map(int, input().split())
    res = 0
    for i in range(n+1):
        for j in range(n+1):
            if r*i + g*j <= n:
                if (n-(r*i + g*j)) % b==0:
                    res += 1           
    print(res)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

li = [r, g, b]
li.sort(reverse=True)

num_max_0 = n//li[0]
num_max_1 = n//li[1]

ans = 0
for num_0 in range(num_max_0 + 1):
    for num_1 in range(num_max_1 + 1):
        ball_01 = num_0*li[0] + num_1*li[1]
        ball_2 = n - ball_01
        
        if ball_2 >= 0 and ball_2 % li[2] == 0:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
c=0
for i in range(-(-n//r)+1):
  for j in range(-(-n//g)+1):
    x=n-(i*r+j*g)
    if x>=0 and x%b==0:
      c+=1
print(c)

Submission status: Time Limit Exceeded

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

c = 0
for r in range(N + 1):
	for g in range(N + 1):
		if N < r * R + g * G:
			break
		f = (N - r * R - g * G) % B
		b = (N - r * R - g * G) // B
		if not f and (0 <= b) and (N == (r * R + g * G + b * B)): 
			#print(r, g, b)
			c += 1
print(c)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
cnt = 0
for i in range(int(N/R)+1):
    r = i*R
    for j in range(int(N/G)+1):
        g = j*G
        if N-g-r >= 0 and(N-g-r) % B == 0:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = [int(n) for n in input().split()]

count = 0
for r in range(N//R + 1):
    for g in range(N//G + 1):
        if (N - (R * r + G * g)) % B == 0:
            b = (N - (R * r + G * g)) / B
            if  0 <= b <=  N//B:
                count += 1

print(count)

Submission status: Time Limit Exceeded

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

cnt = 0

for i in range(N//R + 1) :
    for j in range(N//G + 1) :
        if N - R*i - G*j >= 0 :
            if (N - R*i - G*j) % B == 0:
                cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int, input().split())
ans = 0
for i in range((n+1)//r+1):
    for j in range((n+1)//g+1):
        k = n - (i*r + j*g)
        if k < 0:
            break
        elif k >= 0 and k%b == 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    R,B,G,N = list(map(int,input().split(' ')))
    cnt = 0
    for i in range(N//R+1):
        for j in range(N//G+1):
            if (N-(R*i+G*j))//B == (N-(R*i+G*j))/B and (N-(R*i+G*j))/B >=0:
                cnt +=1
    print(cnt)

if __name__ =='__main__':
    main()