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:
#b
r, g, b, n = (int(_) for _ in input().split())
red = n // r
sets = []
ans = 0
for i in range(red + 1):
    remainder = n - (r*i)
    green = remainder // g
    if remainder == 0:
        ans += 1
    else:
        for j in range(green+1):
            nremainder = remainder - j*g
            if nremainder == 0:
                ans += 1
            elif nremainder > 0 and nremainder % b == 0:
                k = nremainder // b
                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//R + 1):
    Rr = R*r
    for g in range((N-Rr)//G + 1):
        Gg = G*g
        Rr_plus_Gg = Rr + Gg
        for b in range((N-Rr-Gg)//B + 1):
            if Rr_plus_Gg + B*b == N:
                count += 1
                break

print(count)

Submission status: Time Limit Exceeded

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

iB, iG, iR = sorted([R, G, B])

ir = N // iR + 1
ig = N // iG + 1
ib = N // iB + 1

ans = 0
for i in range(ir):
    for j in range(ig):
        tmp = i*iR + j*iG
        if tmp <= N and (N - tmp) % iB == 0:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
data = list(map(int, input().split()))

R = data[0]
G = data[1]
B = data[2]
N = data[3]

# ループが少なくなるように、大きい順に回す
box = sorted([R, G, B])
count = 0
for i in range(int(N / box[2])+1):
    for j in range(int(N / box[1])+1):
        if i * box[2] + j * box[1] > N:
            break
        # i,jが決まればkは回さなくていい
        if (N - (i * box[2] + j * box[1])) % box[0] == 0:
            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) // R + 1):
    for g in range((n - r * R + 1) // G + 1):
        b = n - (r * R + g * G)
        if b % B == 0 and 0 <= b / B <= n:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

tmp = [R, G, B]
tmp.sort()
R, G, B = tmp[2], tmp[1], tmp[0]


num_R = N // R + 1
num_G = N // G
RG = np.zeros((num_R, num_G+1))

RG[:, 0] = [N - R*i for i in range(num_R)]

for j in range(num_G):
    RG[:, j+1] = RG[:, j] - G

check = lambda x: 0 if x < 0 else 1 if x == 0 else 1 if x%B == 0 else 0

a = []
count = 0
for i in range(len(RG)):
    a = list(map(check, RG[i]))
    count += sum(a)

print(count)

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, -1): 
    new1 = N - r*R
    for g in range(new1//G, -1, -1):
        new2 = new1 - g*G
        c += len([b for b in range(new2//B, -1, -1) if b*B == new2])

print(c)

Submission status: Time Limit Exceeded

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

c = N//R
d = N//G

count = 0

for r in range(c + 1):
    for g in range(d + 1):
        if R*r <= N and G*g <= N and R*r + G*g <= N:
            f = (N - R*r - G*g) % B
            if f == 0 and B != 0:
                count = count + 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
r, g, b, n = map(int, input().split())
cnt = 0
for red in range(n // r + 1):
    for green in range(n // g + 1):
        blue = n - red * r - green * g
        if blue >= 0 and blue % b == 0:
            cnt += 1
print(cnt)

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//G +1):
    n = N-r*R-g*G
    
    if n>=0:
      if n%B==0:

        ans+=1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int, input().split())
cn = 0
for r in range(N//R + 1):
    for g in range((N - R*r)//G + 1):
        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  = list(map(int, input().split()))

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

Submission status: Time Limit Exceeded

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

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

a = list()
a.append(r)
a.append(g)
a.append(b)
a.sort(reverse=True)
r, g, b = a


count = 0

for i in range(0, n//r+1):
    for j in range(0, n//g+1):
        if (n - i*r - j*g) % b == 0 and (n - i*r - j*g) >= 0:
            count += 1
            continue

# for i in range(0, n+1):
#     for j in range(0, n+1):
#         for k in range(0, n+1):
#             if r*i + g*j + b*k == n:
#                 count += 1


print(count)

Submission status: Time Limit Exceeded

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

l = sorted([R, G, B])
f = lambda i, j: l[2]*i + l[1]*j

count = 0
for i in range(int(N / l[2]) + 1):
  for j in range(int((N-l[2]*i) / l[1]) + 1):
      if (N - f(i, j)) % l[0] == 0:
        count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int, input().split())
cn = 0
for r in range(N//R + 1):
    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:
import bisect

R, G, B, N = list(map(int, input().split()))
ans = 0
r = [R*i for i in range(N//R+1)]
g = [G*i for i in range(N//G+1)]
b = [-1] + [B*i for i in range(N//B+1)] + [10**20]

for x in r:
    for y in g:
       n = N - x - y
       if n < 0:
           break
       idx = bisect.bisect_left(b, n)
       if b[idx] == n:
           ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
r,g,b,n=IL()
L=[r,g,b]
L.sort()
s,m,l=L
ans=0
for i in range(n//l+1):
    for j in range(n//m+1):
        if n-i*l-j*m<0:
            break
        elif (n-i*l-j*m)%s==0:
            ans+=1
            
print(ans)

Submission status: Time Limit Exceeded

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

RGB = [R, G, B]

RGB.sort(reverse = True)
a = N / RGB[2]

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

    if N < RGB[0]*i:
        break 
    
    else:
        for s in range(int(a)+1):
            tmp = N - RGB[0]*i - RGB[1]*s
            if tmp < 0:
                break
            
            tmp = tmp / RGB[2]

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

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-r*i+1):
    if (n-r*i-g*j) % b == 0 and (n-r*i-g*j) >=0:
      count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
#input
a = list(map(int,input().split())) #input from array of integer like "1 2 3"

range_r = a[3]//a[0]+2
range_g = a[3]//a[1]+2
range_b = a[3]//a[2]+2
cnt = 0
r = 0
g = 0
b = 0
for r in range(range_r):
  if r*a[0] > a[3]:
    break
  for g in range(range_g):
    if r*a[0]+g*a[1] > a[3]:
      break
    for b in range(range_b):
      #print("{},{},{}".format(r,g,b))
      nn = r*a[0]+g*a[1]+b*a[2]
      if nn > a[3]:
        break
      if nn == a[3]:
        cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

RGB = [R, G, B]
RGB.sort(reverse=False)

c = 0
for r in range(N//RGB[0], -1, -1): 
    new1 = N - r*RGB[0]
    for g in range(new1//RGB[1], -1, -1):
        new2 = new1 - g*RGB[1]
        c += len([b for b in range(new2//RGB[2], -1, -1) if b*RGB[2] == new2])

print(c)

Submission status: Time Limit Exceeded

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

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

count = 0

for i in range(0, n//r+1):
    for j in range(0, n//g+1):
        if (n - i*r - j*g) % b == 0 and (n - i*r - j*g) >= 0:
            count += 1

# for i in range(0, n+1):
#     for j in range(0, n+1):
#         for k in range(0, n+1):
#             if r*i + g*j + b*k == n:
#                 count += 1


print(count)

Submission status: Time Limit Exceeded

Solution code:
A,B,C,N=map(int, input().split())
count=0
for x in range(N+1):
    for y in range(N+1):
        for z in range(N+1):
            if N==x*A+y*B+z*C:
                count+=1
                
print(count)

Submission status: Time Limit Exceeded

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

ans = 0

for x in range(n + 1):
    w1 = r*x
    if w1 >n:
        break
    else:
        for y in range(n + 1):
            w2 = w1 + g*y
            if w2 > n:
                break
            else:
                for z in range(n + 1):
                    w3 = w2 + b * z
                    if w3 > n:
                        break
                    elif w3 == n:
                        ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

for r in range(N+1):
    if r*R >= N+1:
        continue
    elif r*R == N:
        count += 1
        continue

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

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

print(count)

Submission status: Time Limit Exceeded

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

#num = int(input())
#S = str(input())

r=l[0]
g=l[1]
b=l[2]
N=l[3]
sum = 0
for i in range(int(N/r)+1):
    for j in range(int(N/g)+1):
        for k in range(int(N/b)+1):
            if(i*r+j*g+k*b==N):
                sum+=1
print(sum)

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):
    if (n-r*i-g*j) % b == 0 and (n-r*i-g*j) >=0:
      count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
data = [int(s) for s in input().split()]

r = data[0]
g = data[1]
b = data[2]
n = data[3]
ans = 0

cx = math.floor(n / r)
cy = math.floor(n / g)
"""
x = sympy.Symnbol("x")
y = sympy.Symbol("y")
z = sympy.Symbol("z")

ans = sympy.solve(x * r + y * g + z * b - n)
print(ans)

"""
for x in range(cx + 1):
  for  y in range(cy + 1):
    if (n - r * x - g * y) == 0:
      
      ans += 1
      break
    if (n - r * x - g * y ) < 0:
      break
    if (n - r * x - g* y) % b== 0 :
      ans += 1
     
     
print(ans)

Submission status: Time Limit Exceeded

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

# スペース区切りの整数の入力
r, g, b, n = map(int, input().split())

# 最大の数をそれぞれ求める
max_x = (int)(n / r)
max_y = (int)(n / g)
max_z = (int)(n / b)

# 答えの数
answer_num = 0

# 計算
for x in reversed(range(max_x+1)):
    for y in reversed(range(max_y+1)):
        if x*r+y*g > n:
            continue
        for z in range(max_z+1):
            if x*r+y*g+z*b > n:
              continue
            elif x*r+y*g+z*b == n:
                answer_num += 1
            else:
                pass

# 出力
print(answer_num)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
r_max = N//R
g_max = N//G
n = 0
r = 0
while r <= r_max :
    num_gb = N - r*R
    g = 0
    while g <= g_max:
        b = num_gb - g*G
        mod = b % B
        g += 1
        if mod == 0 and b >= 0:
            n += 1            
        else:
            continue
    r +=1
    continue
print(n)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = [int(c) for c in input().split()]
ir = N // R + 1
ig = N // G + 1
ib = N // B + 1
ans = 0
for i in range(ir):
    for j in range(ig):
        tmp = i*R + j*G
        if tmp <= N and (N - tmp) % B == 0:
            ans += 1
#         for k in range(ib):
#             if i*R+j*G+k*B == N:
#                 ans += 1
#             print(f'{(i,j,k)} {i*R+j*G+k*B}')

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
data = list(map(int, input().split()))

R = data[0]
G = data[1]
B = data[2]
N = data[3]

# ループが少なくなるように、大きい順に回す
box = sorted([R, G, B])
count = 0
for i in range(int(N / box[0])+1):
    for j in range(int(N / box[1])+1):
        if i * box[0] + j * box[1] > N:
            break
        # i,jが決まればkは回さなくていい
        if (N - (i * box[0] + j * box[1])) % box[2] == 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:

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

count = 0

for r in range(0, 3001):
    if R*r>3000:
        break
    for g in range(0, 3001):
        if R * r + G * g > 3001:
            break
        for b in range(0, 3001):
            num = R*r+G*g+B*b
            if num == N:
                count += 1
            elif num > N:
                break

print(count)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
ans = 0
RGB = sorted([R,G,B],reverse=True)
R,G,B = RGB[0],RGB[1],RGB[2]
for r in range(int(N/R)+1):
    for g in range(int((N-R*r)/G)+1):
        for b in range(int((N-(R*r+G*g))/B)+1):
            if(R*r+G*g+B*b == N):
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int, input().split())
r_n = n//r
g_n = n//g
b_n = n//b
# print(r_n)
# print(g_n)
# print(b_n)
count = 0
ans = len([0 for rr in range(r_n+1) for gg in range(g_n+1) for bb in range(b_n+1) if rr*r + gg*g + bb*b == n])
# for rr in range(r_n+1):
#     for gg in range(g_n+1):
#         for bb in range(b_n+1):
#             if rr*r + gg*g + bb*b == n:
#                 count += 1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

count = 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:
                count += 1

print(count)

Submission status: Time Limit Exceeded

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

a= 0
b= 0

l.sort()

for i in range (0, (l[3])+1):
    for j in range (0, 1 + (l[3]) - i):
        for k in range (0, 1 + (l[3]) - i - j):
            if ((l[0] *i + l[1]*j +l[2]*k) == l[3] ):
                a += 1
                        

print(a)

Submission status: Time Limit Exceeded

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

a2 = d//a
b2 = d//b
c2 = d//c

for i in range(a2 + 1):
    for j in range(b2 + 1):
        for k in range(c2 + 1):
            sum = a * i + b * j + c * k
            if sum == d:
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = input().split()
r_max = int(N)//int(R)
g_max = int(N)//int(G)
n = 0
r = 0
while r <= r_max :
    num_gb = int(N) - r*int(R)
    g = 0
    while g <= g_max:
        b = num_gb - g*int(G)
        mod = b % int(B)
        g += 1
        if mod == 0 and b >= 0:
            n += 1            
        else:
            continue
    r +=1
    continue
print(n)

Submission status: Time Limit Exceeded

Solution code:
data = [int(s) for s in input().split()]

r = data[0]
g = data[1]
b = data[2]
n = data[3]
ans = 0

cx = n // r
cy = n// g
"""
x = sympy.Symnbol("x")
y = sympy.Symbol("y")
z = sympy.Symbol("z")

ans = sympy.solve(x * r + y * g + z * b - n)
print(ans)

"""
for x in range(cx + 1):
  for  y in range(cy + 1):
    if (n - r * x - g * y) == 0:
      
      ans += 1
      break
    if (n - r * x - g * y ) < 0:
      break
    if (n - r * x - g* y) % b== 0 :
      ans += 1
     
     
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力

import math

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

input_list = [R ,G, B]
sort_list = sorted(input_list, reverse=True)

R = sort_list[0]
G = sort_list[1]
B = sort_list[2]

max_r = math.floor(N / R)

count = 0

for r in range(max_r + 1):
    
    max_g = math.floor((N - R * r) / G)    
    
    for g in range(max_g + 1):
        
        b = math.floor((N - R * r - G * g) / B)        

        if (r * R + g * G + b * B) == N:
            count += 1
                
# 出力
print("{}".format(count))

Submission status: Time Limit Exceeded

Solution code:
r, g, b, n = map(int, input().split())
s_rgb = sorted([r, g, b], reverse=True)
result = 0
for i in range(int(n / s_rgb[0]) + 1)[::-1]:
    for j in range(int((n - s_rgb[0] * i) / s_rgb[1]) + 1)[::-1]:
        if s_rgb[0] * i + s_rgb[1] * j > n:
            break
        for k in range(int((n - s_rgb[0] * i - s_rgb[1] * j) / s_rgb[2]) + 1)[::-1]:
            if s_rgb[0] * i + s_rgb[1] * j + s_rgb[2] * k > n:
                break
            if s_rgb[0] * i + s_rgb[1] * j + s_rgb[2] * k == n:
                result += 1
                break
print(result)

Submission status: Time Limit Exceeded

Solution code:
inp = list(map(int,input().split()))
r = inp[0]
g = inp[1]
b = inp[2]
n = inp[3]

n_r = int(n / r) + 1
n_g = int(n / g) + 1
n_b = int(n / b) + 1

count = 0
for i in range(n_r):
    for j in range(n_g):
        for k in range(n_b):
            if (r*i)+(g*j)+(b*k) == n:
                count += 1

print(count)

Submission status: Time Limit Exceeded

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

ans = []
for x in range(N+1):
    for y in range(N+1):
        for z in range(N+1):
            if x*R+y*G+z*B==N:
                
                ans.append([x,y,z])
print (len(ans))

Submission status: Time Limit Exceeded

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

# スペース区切りの整数の入力
r, g, b, n = map(int, input().split())

# 最大の数をそれぞれ求める
max_x = (int)(n / r)
max_y = (int)(n / g)
max_z = (int)(n / b)

# 答えの数
answer_num = 0

# 計算
for x in reversed(range(max_x+1)):
    for y in reversed(range(max_y+1)):
        if x*r+y*g > n:
            continue
        for z in reversed(range(max_z+1)):
            calc = x*r+y*g+z*b
            if x*r+y*g+z*b == n:
                answer_num += 1

# 出力
print(answer_num)

Submission status: Time Limit Exceeded

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

ans = int(0)
x = int(N//R)

for i in range(x+1):
    t = N-i*R
    y = int(t//G)
    for j in range(y+1) :
        s = int(N-R*i-G*j)
        if s%B==0 : ans +=1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N=map(int,input().split())
r,g,b,count=0,0,0,0
while(B*b<=N):
	g=0
	while(G*g<=N-B*b):
		r=(-G*g-B*b+N)/R
		if float(r).is_integer():
			count+=1
		g+=1
	b+=1
print(count)

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-R+1):
        for B in range (n-R-G+1):
            if (n == (r*R+g*G+b*B)):
                count = count+1
print(count)

Submission status: Time Limit Exceeded

Solution code:
r, g, b, n = map(int, input().split())
s_rgb = sorted([r, g, b], reverse=True)
result = 0
for i in range(int(n / s_rgb[0]) + 1)[::-1]:
    for j in range(int((n - s_rgb[0] * i) / s_rgb[1]) + 1)[::-1]:
        if s_rgb[0] * i + s_rgb[1] * j > n:
            break
        for k in range(int((n - s_rgb[0] * i - s_rgb[1] * j) / s_rgb[2]) + 1)[::-1]:
            if s_rgb[0] * i + s_rgb[1] * j + s_rgb[2] * k == n:
                result += 1
                break
print(result)

Submission status: Time Limit Exceeded

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

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

print(result)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
ans = 0
RGB = sorted([R,G,B],reverse=True)
R,G,B = RGB[0],RGB[1],RGB[2]
for r in range(int(N/R)+1):
    for g in range(int((N-R*r)/G)+1):
        for b in range(int((N-(R*r+G*g))/B)+1):
            if(R*r+G*g+B*b == N):
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import fractions
a,b,c,n = map(int,input().split())
d = fractions.gcd(b,c)
b = b//d
c = c//d
#print(d)
ans = 0
x,y,z = 0,0,0
while a*x <= n:
  m = n-a*x
  if m%d > 0:
    continue
  m = m//d
  y = 0
  f = 0
  while m-b*y>= 0 and y < c:
    if (m-b*y)%c == 0:
      f = 1
      break
    y += 1
  ans += f*((m-b*y)//c//b+1)
  x += 1
print(ans)

Submission status: Time Limit Exceeded

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

r_max = int(N)//int(R)
g_max = int(N)//int(G)
n = 0
r = 0
g = 0

while r <= r_max :
    num_gb = int(N) - r*int(R)
    g = 0
    while g <= g_max:
        b = num_gb - g*int(G)
        mod = b % int(B)
        g += 1
        if mod == 0 and b>=0:
            n += 1            
        else:
            continue
    r +=1
    continue
print(n)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
counter = 0
R, G, B = sorted([R, G, B])[::-1]

r = 0
while r * R <= N:
  g = 0
  if B == 1:
    counter += (N - r*R)//G + 1
    r += 1
    continue
  while r*R + g*G <= N:
    b = (N - r*R - g*G)/B
    if b == int(b):
      counter += 1
      g += 1
  r += 1
print(counter)

Submission status: Time Limit Exceeded

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

RGB = [R, G, B]
RGB.sort(reverse=False)

c = 0
for r in range(N//RGB[0], -1, -1): 
    new1 = N - r*RGB[0]
    for g in range(new1//RGB[1], -1, -1):
        new2 = new1 - g*RGB[1]
        for b in range(new2//RGB[2], -1, -1):
            if b*RGB[2] == new2:
                c += 1

print(c)

Submission status: Time Limit Exceeded

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

#sum_rg = collections.Counter()  # TLE
sum_rg = collections.defaultdict(int)

for i in range(n + 1):
    if n < r*i:
        break
    for j in range(n + 1):
        if n < r*i + g*j:
            break
        sum_rg[r*i + g*j] += 1

ans = 0
for k in range(n + 1):
    if n < b*k:
        break
    ans += sum_rg[n - b*k]

#print(sum_rg)
print(ans)

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):
        
        for k in range(N+1):
        
            ans = R * i + G * j + B * k
            
            if ans == N:
                count += 1
                #print(i, j, k)
            
print(count)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N=map(int,input().split())
r,g,b,count=0,0,0,0
while(B*b<=N):
	g=0
	while(G*g<=N-B*b):
		r=(-G*g-B*b+N)/R
		if (float(r).is_integer())&(r>=0):
			count+=1
		g+=1
	b+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int, input().split())
r = 0
rList = [i*R for i in range(int(N/R)+1)]
gList = [i*G for i in range(int(N/G)+1)]

for i in rList:
    for j in gList:
        k = i + j
        if ((N-k) % B == 0 and N-k >= 0):
            r += 1

print(r)

Submission status: Time Limit Exceeded

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

r_max = int(N)//int(R)
g_max = int(N)//int(G)
n = 0
#nはパターン数
r = 0
g = 0

while r <= r_max :
    num_gb = int(N) - r*int(R)
    g = 0
    while g <= g_max:
        b = num_gb - g*int(G)
        mod = b % int(B)
        if mod == 0 and b>=0:
            n += 1
            g += 1            
        else:
            g += 1
            continue
    r +=1
    continue
print(n)

Submission status: Time Limit Exceeded

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

box = sorted([R,G,B], key=lambda x:-x)
nums = [N//b for b in box]
for i in range(nums[0]+1):
    if (nums[0]-i)*box[0] + nums[1]*box[1] + nums[2]*box[2] < N:
        break
    for j in range(nums[1]+1):
        resj = (nums[0]-i)*box[0] + (nums[1]-j)*box[1]
        if resj + nums[2]*box[2] < N:
            break
        if resj > N:
            continue
        if (N-resj)%box[2]!=0:
            continue
        num += 1

print(num)

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):
        x = i * R
        y = j*G
        z = N - x-y
        if z>= 0 and z%B == 0:
            ans += 1
print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
ans = 0
tmp = [R, G, B]
tmp.sort()

rmax = N // tmp[2]
gmax = N // tmp[1]

for i in range(rmax + 1):
  for j in range(gmax + 1):
    if (N - i * tmp[2] - j * tmp[1]) < 0:
      break
    if (N - i * tmp[2] - j * tmp[1]) % tmp[0] == 0:
      ans += 1
#      print(ans, i, j)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
data = [int(s) for s in input().split()]

r = data[0]
g = data[1]
b = data[2]
n = data[3]
ans = 0
"""
x = sympy.Symnbol("x")
y = sympy.Symbol("y")
z = sympy.Symbol("z")

ans = sympy.solve(x * r + y * g + z * b - n)
print(ans)

"""
for x in range(n+1):
  for  y in range(n+1):
    if (n - r * x - g * y) == 0:
      
      ans += 1
      break
    if (n - r * x - g * y ) < 0:
      break
    if (n - r * x - g* y) % b== 0 :
      ans += 1
     
     
print(ans)

Submission status: Time Limit Exceeded

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

Rmax = N // R
Gmax = N // G

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

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力

import math

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

max_r = math.floor(N / R)

count = 0

for r in range(max_r + 1):
    
    max_g = math.floor((N - R * r) / G)    
    
    for g in range(max_g + 1):
        
        b = math.floor((N - R * r - G * g) / B)        

        if (r * R + g * G + b * B) == N:
            count += 1
                
# 出力
print("{}".format(count))

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N=map(int,input().split())
r,g,b,count=0,0,0,0
while(B*b<=N):
	g=0
	while(G*g<=N):
		r=(-G*g-B*b+N)/R
		if (float(r).is_integer())&(r>=0):
			count+=1
		g+=1
	b+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
a=[r,g,b]
a.sort()
a.reverse()
count=0
for i in range(int(n/a[0]+1)):
  for j in range(int((n-i*a[0])/a[1]+1)):
    if (n-i*a[0]-j*a[1])<0:break
    if (n-i*a[0]-j*a[1])%a[2]==0: count+=1
print(count)

Submission status: Time Limit Exceeded

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

for i in range(maxr + 1):
    for j in range(((N - R * i) // G ) + 1):
        if (N - R * i - G * j) % B == 0 and (N - R * i - G * j) >= 0:
            result += 1
        if N - R * i - G * j < 0:
            break

print(result)

Submission status: Time Limit Exceeded

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

l.reverse()
r_max=N//l[0]
g_max=N//l[1]
RR=l[0]
GG=l[1]
BB=l[2]
ans=0
for r in range(r_max+1):
    res=N-r*RR
    for g in range(g_max+1):
        x=res-GG*g
        if x>=0 and x%BB==0:
            ans+=1
            
print(ans)

Submission status: Time Limit Exceeded

Solution code:
x=input()
xx=x.split()
R=int(xx[0])
G=int(xx[1])
B=int(xx[2])
N=int(xx[3])
b=0
 
for r in range(1,300):
  for g in range(1,300):
    for b in range(1,300):
      if R*r+G*g+B*b==N:
        b+=1
print(b)

Submission status: Time Limit Exceeded

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

i = -1
j = -1
k = -1
times = 0

while True:
    i += 1
    if i*R > N:
        i = -1
        break
        
    while True:          
        j += 1
        if (i*R + j*G) > N:
            j = -1
            break
            
        if (N - i*R - j*G) % B == 0:
            times += 1
                
print(times)

Submission status: Time Limit Exceeded

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

lst=[r,g,b]
lst.sort()
r=lst[2]
g=lst[1]
b=lst[0]

rlim=n//r
blim=n//b

blist = np.array([i*b for i in range(blim+1)])

def binary_search(list, item):
    low = 0
    high = len(list) - 1

    while low <= high:
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
            return True
        if guess > item:
            high = mid -1
        else:
            low = mid + 1
    return False


cnt=0

for i in range(rlim+1):
    glim=(n-i*r)//g
    for j in range(glim+1):
        if binary_search(blist,n-i*r-j*g):
            cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
x=input()
xx=x.split()
R=int(xx[0])
G=int(xx[1])
B=int(xx[2])
N=int(xx[3])
b=0

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

Submission status: Time Limit Exceeded

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

sum_rg = collections.Counter()

for i in range(n + 1):
    if n < r*i:
        break
    for j in range(n + 1):
        if n < r*i + g*j:
            break
        sum_rg[r*i + g*j] += 1

ans = 0
for k in range(n + 1):
    if n < b*k:
        break
    ans += sum_rg[n - b*k]

#print(sum_rg)
print(ans)