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:
R,G,B,N=list(map(int,input().split()))
ans=[]
if 1<=R<=3000 and 1<=G<=3000 and 1<=B<=3000 and 1<=N<=3000:
	limR=N//R
	for r in range(limR+1)[::-1]:
		zanGB=N-r*R
		limG=zanGB//G
		for g in range(limG+1):
			zanB=zanGB-g*G
			if zanB%B==0:
				b=zanB//B
				ans.append([r,g,b])
print(len(ans))

Submission status: Time Limit Exceeded

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

ans=0
for i in [i*r for i in range(n//r+1)]:
    for j in [i*g for i in range(n//g+1)]:
        A=n-i-j
        if A%b==0 and A>=0:

            ans+=1

print(ans)

Submission status: Time Limit Exceeded

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

x=[i*r for i in range(n//r+1)]
y=[i*g for i in range(n//g+1)]
z=[i*b for i in range(n//b+1)]
ans=0
for i in x:
    for j in y:
        A=n-i-j
        if A in z:
            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(3001):
    for j in range(3001):
        v = i * r + j * g
        if n >= v and (n - v) % b == 0:
            ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,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 == r*x+g*y+b*z and n>0:
                count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = (int(x) for x in input().split())
s = 0
t = 0
cnt = 0
for s in range(n // r + 1):
  for t in range(n // g + 1):
    if (n - (s * r) - (t * g)) % b == 0 and (n - (s * r) - (t * g)) >= 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 - R*i) // G + 1):
        if (N - i*R - j*G) / B >= 0 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
for i in range(N // R + 1):
    for j in range(N-i+1):
        if (N - i*R - j*G) / B >= 0 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
for i in range(N+1):
    for j in range(N-i+1):
        if (N - i*R - j*G) / B >= 0 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
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) % B == 0:
            ans += 1
            
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().strip().split())
R, G, B = sorted([R,G,B], reverse=True)

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

        if z < 0:
            break

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
read = input
A = list(map(int, read().split()))
n = A[-1]
A = A[:3]
A.sort() # ascending
ans = 0
# print(A)
for i in range(n+1):
    for j in range(n+1):
        tmp = A[0]*i + A[1] * j
        if tmp > n:break
        tmp = n - tmp
        if tmp % A[2] == 0:
#             print(i, j, tmp//A[2])
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# div2019B - RGB Boxes
r, g, b, n = list(map(int, input().rstrip().split()))
x = n // min(r, g, b) + 1
cnt = 0
for i in range(x):
    for j in range(x):
        if (n - (i * r + j * g)) >= 0 and (n - (i * r + j * g)) % b == 0:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = (int(x) for x in input().split())
s = 0
t = 0
cnt = 0
for s in range(3000):
  for t in range(3000):
    if (n - (s * r) - (t * g)) % b == 0 and (n - (s * r) - (t * g)) >= 0:
      cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

counter = 0
for r in range((N // R) + 1):
    for g in range(((N - (r * R)) // G) + 1):
        w_b_sum = N - ((R * r) + (G * g))

        if w_b_sum % B == 0 and w_b_sum >= 0 and w_b_sum == N - ((R * r) + (G * g)):
            # print(r, g, (w_b_sum // B))
            counter += 1
print(counter)

Submission status: Time Limit Exceeded

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

counter = 0
for r in range(N + 1):
    for g in range(((N - (r * R)) // G) + 1):
        w_b_sum = N - ((R * r) + (G * g))

        if w_b_sum % B == 0 and w_b_sum >= 0 and w_b_sum == N - ((R * r) + (G * g)):
            # print(r, g, (w_b_sum // B))
            counter += 1
print(counter)

Submission status: Time Limit Exceeded

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

counter = 0
for r in range(N + 1):
    for g in range(N + 1 - (r * R)):
        w_b_sum = N - ((R * r) + (G * g))

        if w_b_sum % B == 0 and w_b_sum >= 0 and w_b_sum == N - ((R * r) + (G * g)):
            # print(r, g, (w_b_sum // B))
            counter += 1
print(counter)

Submission status: Time Limit Exceeded

Solution code:
a, b, c, n = map(int, input().split())
aa =[a,b,c]
aa.sort()
r = aa[0]
g = aa[1]
b = aa[2]
 
count = 0
for i_r in range(0,int(n/r)+1):
    if (n - r*i_r)<0:continue
    for i_g in range(0,int((n-r*i_r)/g)+1):
        if (n - r*i_r - g*i_g)<0:continue
        if 0==((n - r*i_r - g*i_g)%b):
 
            count = count + 1
 
print(count)

Submission status: Time Limit Exceeded

Solution code:
a, b, c, n = map(int, input().split())
aa =[a,b,c]
aa.sort()
r = aa[2]
g = aa[1]
b = aa[0]
 
count = 0
for i_r in range(0,int(n/r)+1):
    if (n - r*i_r)<0:continue
    for i_g in range(0,int((n-r*i_r)/g)+1):
        if (n - r*i_r - g*i_g)<0:continue
        if 0==((n - r*i_r - g*i_g)%b):
 
            count = count + 1
 
print(count)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
cnt = 0
R, G, B, N = map(int, input().split())
rgb = sorted([R,G,B], reverse=True)

for r in range((N//rgb[0])+1):
    for g in range((N-r*rgb[0])//rgb[1]+1):
        m = N - r*rgb[0] - g*rgb[1]
        if m == 0 or (m % rgb[2] == 0 and m >= rgb[2]):
            cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys

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

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
cnt = 0
for r in range(3001):
    for g in range(3001):
        V = r * R + g * G 
        if N >= V and (N - V) % B == 0:
            cnt += 1
        else:
            continue
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):
    if N - r * R < 0:
        break
    for g in range((N - R * r) // G + 1):
        tmp = N - r * R - g * G
        if tmp < 0:
            break
        if tmp % B == 0 and tmp // 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):
    if N - r * R < 0:
        break
    for g in range(N // G + 1):
        tmp = N - r * R - g * G
        if tmp < 0:
            break
        if tmp % B == 0 and tmp // B >= 0:
            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+1):  
  for j in range(n+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())

ans = 0
for r in range(3000 // R + 1):
    if N - r * R < 0:
        break
    for g in range(3000 // G + 1):
        tmp = N - r * R - g * G
        if tmp < 0:
            break
        if tmp % B == 0 and tmp // 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(3000 // R + 1):
    if N - r * R < 0:
        continue
    for g in range(3000 // G + 1):
        tmp = N - r * R - g * G
        if tmp < 0:
            break
        if tmp % B == 0 and tmp // 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(3001):
    if N - r * R < 0:
        continue
    for g in range(3001):
        tmp = N - r * R - g * G
        if tmp < 0:
            break
        if tmp % B == 0 and tmp // 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(3001):
    for g in range(3001):
        tmp = N - r * R - g * G
        if tmp < 0:
            break
        if tmp % B == 0 and tmp // 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(3001):
    for g in range(3001):
        tmp = N - r * R - g * G
        if tmp % B == 0 and tmp // B >= 0:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

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

print(count)

Submission status: Time Limit Exceeded

Solution code:
r, g, b, n = map(int, input().split())
r_num = n // r
g_num = n // g
b_num = n // b
count = 0
for i in range(r_num+1):
    r_remain = n - r * i
    if r_remain == 0:
        count += 1
    else:
        for j in range(g_num+1):
            g_remain = r_remain - g * j
            if g_remain == 0:
                count += 1
            elif g_remain > 0:
                if g_remain % b == 0:
                    count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
import math
import statistics as sta



def main():
    r,g,b,n=list(map(int,input().split()))
  #  print(r,g,b,n)
    ans=0
    for i in range(n+1):
        for j in range(n+1):
            for z in range(n+1):
                if n==r*i+g*j+b*z:
                    ans +=1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

x_max= N//R
y_max= N//G
ans=0

for x in range(x_max+1):
    for y in range(y_max+1):

        z= (N-R*x-G*y)//B

        if z >=0 and (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())
ans = 0
nr = n // r
ng = n // g
for i in range(nr + 1):
    for j in range(ng + 1):
        tmp = n - i * r - j * g
        if tmp % b == 0 and tmp >= 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
r, g, b, n = map(int, input().split())
cnt = 0
nr = n // r
ng = n // g
for i in range(nr + 1):
    for j in range(ng + 1):
        tmp = n - i * r - j * g
        if tmp >= 0 and tmp % 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):
    for j in range(n + 1):
        if i * r + j * g == n:
            ans += 1
        elif (n - (i * r + j * g)) >= 0 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())
count = 0
for i in range(N+1):
    for j in range(N+1):
        tmp = N-(R*i)-(G*j)
        if tmp >= 0 and tmp % B == 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
[r,g,b,n]=map(int,input().split())
out=0
for R in range(n+1):
        if r*R>=n+1:
                break
        for G in range (n+1):
                if r*R+g*G>=n+1:
                        break
                for B in range(n+1):
                        if r*R+g*G+B*b>=n+1:
                                break
                        if r*R+g*G+B*b==n:
                                out+=1
print(out)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int,input().split())
count = 0
i_range = N//R+1
j_range = N//G+1

for i in range (i_range):
    for j in range (j_range):
        if (N - i*R - j*G)%B == 0 and (N - i*R - j*G)>=0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
[r,g,b,n]=map(int,input().split())
out=0
for R in range(n+1):
        if r*R>=n+1:
                break
        for G in range (3001):
                if r*R+g*G>=n+1:
                        break
                for B in range(3001):
                        if r*R+g*G+B*b>=n+1:
                                break
                        if r*R+g*G+B*b==n:
                                out+=1
print(out)

Submission status: Time Limit Exceeded

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

ans=0

for i in range(N+1):
  if i*R > N:
    break
  else:
    for j in range(N+1):
      if i*R+j*G > N:
        break
      else:
        if N-(i*R+j*G) == 0 or (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
 
for Rx in range(0, N+1, R):
    for Gy in range(0, N+1, G):
        check = N - Rx - Gy
        if check % B == 0 and 0 <= check // B <= N // B:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
ans = 0
 
for x in range(N // R + 1):
    Rx = R * x
    for y in range(N // G + 1):
        check = N - Rx - G * y
        if check % B == 0 and 0 <= check // B <= N // B:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N=(int(x) for x in input().split())
cnt=0
max=[N//R,N//G,N//B]
for r in range(max[0]+1):
    for g in range(max[1]+1):
        for b in range(max[2]+1):
            v=(R*r)+(G*g)+(B*b)
            if v>N:
                continue
            if v==N:
                cnt+=1
print (cnt)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N=(int(x) for x in input().split())
conbo=[]
max=[N//R,N//G,N//B]
for r in range(max[0]+1):
    for g in range(max[1]+1):
        for b in range(max[2]+1):
            v=(R*r)+(G*g)+(B*b)
            if v>N:
                continue
            if v==N:
                conbo.append([r,g,b])
print (len(conbo))

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N=(int(x) for x in input().split())
conbo=[]
max=[N//R,N//G,N//B]
for r in range(max[0]+1):
    for g in range(max[1]+1):
        for b in range(max[2]+1):
            if (R*r)+(G*g)+(B*b)==N:
                conbo.append([r,g,b])
print (len(conbo))

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_2 = n - num_0*li[0] - num_1*li[1]
        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())

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

res=0
tmp=n
tmp1=0
re=n//r+1
ge=n//g+1

for i in range(re):
	tmp = tmp - i*r
	tmp1 = tmp
	for j in range(ge):
		tmp1 = tmp - j*g
		if tmp1 >= 0 and tmp1%b==0:
			res = res + 1
			#print(i, j, int(tmp1/t2[2]))
		tmp1 = tmp
	tmp=n

print(res)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int,input().split())
lis=[r,g,b]
lis.sort()
cnt=0
for i in range(n//lis[2] + 1):
  for l in range((n-i*lis[2])//lis[1]+1):
    for m in range((n-i*lis[2]-l*lis[1])//lis[0]+1):
      if i*lis[2]+l*lis[1]+m*lis[0] == n:
        cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

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

res=0
tmp=n
tmp1=0

for i in range(n//r+1):
	tmp = tmp - i*r
	tmp1 = tmp
	for j in range(n//g+1):
		tmp1 = tmp - j*g
		if tmp1 >= 0 and tmp1%b==0:
			res = res + 1
			#print(i, j, int(tmp1/t2[2]))
		tmp1 = tmp
	tmp=n

print(res)

Submission status: Time Limit Exceeded

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

res=0
tmp=n
tmp1=0

for i in range(n//r+1):
	tmp -= i*r
	tmp1 = tmp
	for j in range(n//g+1):
		tmp1 -= j*g
		if tmp1 >= 0 and tmp1%b==0:
			res+=1
			#print(i, j, int(tmp1/t2[2]))
		tmp1 = tmp
	tmp=n

print(res)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int,input().split())
lis=[r,g,b]
lis.sort()
cnt=0
for i in range(n//lis[2] + 1):
  for l in range(n//lis[1]+1):
    for m in range(n//lis[0]+1):
      if i*lis[2]+l*lis[1]+m*lis[0] == n:
        cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

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

res=0
tmp=n
tmp1=0
t1 = [r,g,b]
t2 = sorted(t1, reverse=True)
#print(t2)

for i in range(n//t2[0]+1):
	tmp -= i*t2[0]
	tmp1 = tmp
	for j in range(n//t2[1]+1):
		tmp1 -= j*t2[1]
		if tmp1 >= 0 and tmp1%t2[2]==0:
			res+=1
			#print(i, j, int(tmp1/t2[2]))
		tmp1 = tmp
	tmp=n

print(res)

Submission status: Time Limit Exceeded

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

sum=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 (n-(i*r)-(j*g))//b>=0:
            sum=sum+1
        #    print(i*r,j*g,(n-(i*r)-(j*g))%b)

print(sum)

Submission status: Time Limit Exceeded

Solution code:
def main():
    R, G, B, N = map(int, input().split())
    n_r = int(N / R)
    n_g = int(N / G)
    count = 0
    for r in range(n_r+1):
        for g in range(n_g+1):
            b = (N - R * r - G * g) // B
            r_b = (N - R * r - G * g) % B
            if b >= 0 and r_b == 0:
                count += 1
    print(count)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

r_max=n//r
g_max=n//g

sum=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 (n-(i*r)-(j*g))//b>=0:
            sum=sum+1
        #    print(i*r,j*g,(n-(i*r)-(j*g))%b)

print(sum)

Submission status: Time Limit Exceeded

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

r_max=n//r
g_max=n//g

sum=0

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

print(sum)

Submission status: Time Limit Exceeded

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

r_max=n//r
g_max=n//g
b_max=n//b

sum=0

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

print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
R, G, B, N = map(int, input().split())

c = 0
for r in range(N//R + 1):
    for g in range(N//G + 1):
        b = (N - r*R - g*G)/B
        if b >= 0 and b.is_integer():
            c += 1
print(c)

Submission status: Time Limit Exceeded

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

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-R*r)//G+1):
		b = (N - R * r - G * g) / B
		if b.is_integer() and b >= 0:
			cnt += 1
print(cnt)

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+1):
		b = (N - R * r - G * g) / B
		if b.is_integer() and b >= 0:
			cnt += 1
print(cnt)

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+1):
		#b = (N - R * r - G * g) / B
		if R * r + G * g == N:
			cnt += 1
		elif ((N - R * r - G * g) / B).is_integer() and ((N - R * r - G * g) / B) > 0:
			cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
# 2019/05/12
# diverta 2019 Programming Contest - B

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

cnt = 0
for i in range(n+1):
    
    rcnt = r * i
    if rcnt > n:
        break
    
    for j in range(n+1):
        gcnt = g * j
        rgcnt = rcnt + gcnt
        if rgcnt > n:
            break

        bcnt = n - rgcnt
        if bcnt % b == 0:
            cnt += 1

print(cnt)

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+1):
		if R * r + G * g == N:
			cnt += 1
		b = (N - R * r - G * g) / B
		if b.is_integer() and b > 0:
			cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

ans=[]

for r in range(int(N/R)+1):
    for g in range(int((N-r*R)/G)+1):
        b=((N-r*R-g*G)/B)
        if b.is_integer():
            ans.append([r,g,b])

print(len(ans))

Submission status: Time Limit Exceeded

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

ans=[]

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).is_integer():
            ans.append([r,g,(N-r*R-g*G)/B])

print(len(ans))

Submission status: Time Limit Exceeded

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

ans=[]

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)+1):
            if r*R+g*G+b*B==N:
                
                ans.append([r,g,b])

print(len(ans))

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 R*r+G*g <= N:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
def box(r,g,b,n):
  count = 0
  for i in range(3000):
    for j in range(3000):
      v = r*i+b*j
      if((n-v)%g==0 and v<=n):
        count+=1
  return count   

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

Submission status: Time Limit Exceeded

Solution code:
R,G,B,n = map(int,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 R*r + G*g + B*b == n:
        c += 1
        break
print(c)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

count = 0

tmp_lst = [R, G, B]
tmp_lst.sort()
X, Y, Z = tmp_lst[0], tmp_lst[1], tmp_lst[2]

x_max = int(N/X)    #   max の中では一番大きい
y_max = int(N/Y)
z_max = int(N/Z)

#print(x_max, y_max, z_max, X, Y, Z)

for z in range(z_max + 1):
    for y in range(y_max + 1):
        tmp = N - z*Z - y*Y
        if tmp < 0:
            break
        if tmp % X == 0 and tmp // X <= x_max:
#            print(tmp // X, y, z)
            count += 1

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8 
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-i*r-j*g>=0 and (n-i*r-j*g)%b==0:
            cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8 
r, g, b, n = map(int, input().split())
a = [r, g, b]
a.sort()
cnt = 0
for i in range(n//a[0]+1):
    for j in range(n//a[1]+1):
        if n-i*a[0]-j*a[1]>=0 and (n-i*a[0]-j*a[1])%a[2]==0:
            cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8 
r, g, b, n = map(int, input().split())
a = [r, g, b]
a.sort()
cnt = 0
for i in range(n//a[2]+1):
    for j in range(n//a[1]+1):
        if n-i*a[2]-j*a[1]>=0 and (n-i*a[2]-j*a[1])%a[0]==0:
            cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int , input().split())
e = 0
A=d//a
B=d//b
C=d//c
for i in range(A+1):
    for l in range(B+1):
        for t in range(C+1):
            if (a*i)+(b*l)+(c*t) == d:
                e+=1
print(e)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,d = map(int , input().split())
e = 0
A=d//a
B=d//b
C=d//c
for i in range(A+1):
    for l in range(B+1):
        for t in range(C+1):
            if (a*i)+(b*l)+(c*t) == d:
                e+=1
print(e)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
r = 0
g = 0
X = N - r*R - g*G
num = 0
while X >= 0:
	while X >= 0:
			if X % B == 0:
				num += 1
			r += 1
			X = N - r*R - g*G
	g += 1
	r = 0
	X = N - r * R - g * G
 
print(num)

Submission status: Time Limit Exceeded

Solution code:

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

for i in range(n+1):
    for j in range(n+1):
        for k in range(n+1):
            if (r*i + g*j + b*k) == n:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
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 = [[N - R*i for i in range(num_R)]]

for j in range(num_G):
    RG.append([RG[-1][i] - G for i in range(num_R)])

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)