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 = map(int, input().split())
count = 0
colors = sorted([r,g,b])
for i in range(1+n//colors[2]):
    for j in range(1+n//colors[1]):
        rest = n - i*colors[2] - j*colors[1]
        if rest >= 0 and rest%colors[0] == 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(1+n//r):
    for j in range(1+n//g):
        rest = n - i*r - g*j
        if rest >= 0 and rest%b == 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
r, g, b, n = [int(num) for num in input().split()]

#総当たり
counter = 0
for r_c in range(0, n // r + 1):
  for g_c in range(0, n // g + 1):
    for b_c in range(0, n // b + 1):
      if (r_c * r + g_c * g + b_c * b) == n:
        counter += 1
print(counter)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(int(N / R) + 1):
    for j in range(int((N - i * R) / 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 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)) >= 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

rmax = N // R + 1

ans = 0
for i in range(rmax):
    gmax = (N - i * R) // G + 1
    for j in range(gmax):
        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())

rmax = N // R + 1
gmax = N // G + 1

ans = 0
for i in range(rmax):
    for j in range(gmax):
        if (N - (i * R + j * G)) % B == 0 and (N - (i * R + j * G)) >= 0:
            ans += 1  # (N-(i*R+j*G))//B
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):
		if (n-r*i-g*j)%b==0 and \
		n-r*i-g*j>=0:
			ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,n=map(int,input().split())
i=0
ans=0
while(R*i<=n):
  j=0
  while(R*i+G*j<=n):
    if((n-R*i-G*j)%B==0):
      ans+=1
    j+=1
  i+=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):
    for g in range(N + 1):
        if (N - (R * r) - (G * g)) % B == 0 and 0 <= ((N - (R * r) - (G * g)) // B) <= 3000:
            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 + 10):
    for g in range(3000 + 10):
        now = N - R * r - G * g
        if now >= 0 and now % B == 0:
            ans += 1
        if now < 0:
            break
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):
    if N - R*i < 0:
        break
    for j in range(N//G+1):
        if N - R * i - G * j < 0:
            break
        if  N -R*i -G*j == 0:
            ans += 1
        elif N -R*i -G*j > 0 and (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 i in range(N//R+1):
    for j in range(N//G+1):
        if N - R * i - G * j < 0:
            break
        if  N -R*i -G*j == 0:
            ans += 1
        elif N -R*i -G*j > 0 and (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 i in range(N//R+1):
    for j in range(N//G+1):
        if  N -R*i -G*j == 0:
            ans += 1
        elif N -R*i -G*j > 0 and (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+1):
    if N < r*R:
        break
    for g in range(3000+1):
        if N < r*R+g*G:
            break
        if (N-r*R-g*G)%B==0:
#            print('({0}-{1}*{2}-{3}*{4})%{5}'.format(N,r,R,g,G,B))
            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+1):
    for g in range(3000+1):
        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(3000+1):
    for g in range(3000+1):
        for b in range(3000+1):
            if r*R+g*G+b*B==N:
                ans+=1
            elif r*R+g*G+b*B>N:
                b=0
                break
        if r*R+g*G>N:
            g=0
            break
    if r*R>N:
        break
print(ans)

Submission status: Time Limit Exceeded

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

#R*r+G*g+B*b==n
ir= int(N/R)+1
ig=int(N/G)+1
ib=int(N/B)+1
s=0
for r in range(ir):
    for g in range(ig):
        if(R*r+G*g>N):
            break;
        if((N-R*r-G*g)%B==0):
            s+=1
print(s)

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):
        t = N - (i * R + j * G)
        if 0 <= t and t % B == 0:
            cnt += 1
            
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
from itertools import product

R, G, B, N = map(int, input().split())
R_max = N // R
G_max = N // G
ans = 0
for r, g in product(range(R_max+1), range(G_max+1)):
    b, r = divmod((N - (r*R + g*G)), B)
    if r == 0 and b >= 0: ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from itertools import product

R, G, B, N = map(int, input().split())
colors = sorted([(N // R, R), (N // G, G), (N // B, B)])
ans = 0
for i, j in product(range(colors[1][0]+1), range(colors[2][0]+1)):
    I = colors[1][1]; J = colors[2][1]; 
    if N >= i*I + j*J and (N - (i*I + j*J)) % colors[0][1] == 0: ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from itertools import product

R, G, B, N = map(int, input().split())
R_max = N // R
G_max = N // G
ans = 0
for r, g in product(range(R_max+1), range(G_max+1)):
    if N >= r*R + g*G and (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())
balls=sorted([r,g,b])
ans=0
for i in range(n//balls[2]+1):
  for j in range((n-(i*balls[2]))//balls[1]+1):
    for k in range((n-i*balls[2]-j*balls[1])//balls[0]+1):
      if i*balls[2]+j*balls[1]+k*balls[0]==n:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)


"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
r,g,b,n= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
s = 0
for i in range(n//r+1):
    for k in range(n//g+1):
        left = n-(r*i+k*g)
        if left%b == 0 and left>=0:s+=1
print(s)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
li = [R, G, B]
li.sort()
R, G, B = li[2], li[1], li[0]
  
  
count = 0
for i in range(int(N/R+1)):
  for j in range(int(N/G+1)):
    k = int((N - R*i - G*j)/B)
    if k < 0:
      continue
    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())
total = 0
ref = 0
count = 0
for i in range(n//r+1):
        for j in range((n-r*i)//g+1):
                total = r*i + g*j
                ref = n - total
                if (ref == 0) or (ref%b == 0):
                        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int,input().split())
total = 0
ref = 0
count = 0
for i in range(n//r+1):
        for j in range((n-r*i)//g+1):
                total = r*i + g*j
                ref = n - total
                if (ref >= 0):
                        if ref%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(int(N/R+1)):
  for j in range(int(N/G+1)):
    k = int((N - R*i - G*j)/B)
    if k < 0:
      continue
    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())
total = 0
ref = 0
count = 0
for i in range(n//r+1):
        for j in range(n//g+1):
                total = r*i + g*j
                ref = n - total
                if (ref >= 0):
                        if ref%b == 0:
                                count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
#n = int(input())
#m = int(input())
#k = int(input())
#n, m = map(int, input().split())
r, g, b, n = map(int, input().split())
#a = list(map(int, input().split()))
#table = []
'''
for i in range h:
    temp = list(map(int, input().split()))
    table.append(temp)
'''
count = 0
for i in range(n//r+1):
    for j in range((n-r*i)//g+1):
        for k in range((n-r*i-g*j)//b+1):
            if r*i+g*j+b*k==n:
                count +=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
#n = int(input())
#m = int(input())
#k = int(input())
#n, m = map(int, input().split())
r, g, b, n = map(int, input().split())
#a = list(map(int, input().split()))
#table = []
'''
for i in range h:
    temp = list(map(int, input().split()))
    table.append(temp)
'''
count = 0
for i in range(n//r+1):
    for j in range(n//g+1):
        for k in range(n//b+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())

ans = 0

for r in range(N//R+1):        #N以内で
  for g in range(N-R*r//G+1):
    #print(r,g, B)
    if (N - R*r - G*g)%B == 0 and (N - R*r - G*g)/B >= 0:
      ans += 1
      #print((N - R*r - G*g)/B)
print(ans)

Submission status: Time Limit Exceeded

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

RGB = sorted([R, G, B], reverse=True)
max1 = N // RGB[0] 

count = 0
for r in range(max1+1):
    max2 = min([N-r, (N-r*RGB[0])//RGB[1]])
    for g in range(max2+1):
        Bb = N - (r*RGB[0] + g*RGB[1])
        if Bb >= 0 and Bb % RGB[2] == 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

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

RGB = sorted([R, G, B], reverse=True)
max1 = N // RGB[0] 

count = 0
for r in range(max1+1):
    for g in range(N-r+1):
        Bb = N - (r*RGB[0] + g*RGB[1])
        if Bb >= 0 and Bb % RGB[2] == 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,n=map(int,input().split())
d=[a,b,c]
d.sort()
a=d[0]
b=d[1]
c=d[2]
e=0
for i in range(0,int(n/c)+1):
  f=n-c*i
  for k in range(0,int(f/b)+1):
    g=f-b*k
    if g/a-int(g/a)==0:
        e=e+1
print(e)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

print(counter)

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

Submission status: Time Limit Exceeded

Solution code:
*j, n = map(int, input().split())
j.sort()
a, b, c = j
count = 0
for y in range(n//b+1):
    for z in range((n-y*b)//c+1):
        if (n - b*y - c*z) % a == 0 and (n - b*y - c*z) >= 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
*j, n = map(int, input().split())
j.sort()
a, b, c = j
count = 0
for y in range(n//b+1):
    for z in range(n//c+1):
        if (n - b*y - c*z) % a == 0 and (n - b*y - c*z) >= 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
*j, n = map(int, input().split())
j.sort()
a, b, c = j
count = 0
for y in range(n//b+1):
    for z in range(n//c+1):
        x = (n - b*y - c*z) / a
        if int(x) == x and x >= 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
a, b, c, n = map(int, input().split())
count = 0
for y in range(n//b+1):
    for z in range(n//c+1):
        x = (n - b*y - c*z) / a
        if int(x) == x and x >= 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
a, b, c, n = map(int, input().split())
count = 0
for y in range(n+1):
    for z in range(n+1):
        x = (n - b*y - c*z) / a
        if int(x) == x and x >= 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
ans=0
ir=0
ig=0
ib=0
li=[]
li.append(r)
li.append(g)
li.append(b)
li.sort()
r=li[0]
g=li[1]
b=li[2]

while n>=ir*r:



            while n>=ig*g:
                    if (n - (ir * r + ig * g)) / b >= 0:
                        if (n - (ir * r + ig * g)) % b == 0:
                            ans = ans + 1
                    ig = ig + 1

            ig=0

            ir=ir+1



print(ans)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
ans=0
ir=0
ig=0
ib=0
li=[]
li.append(r)
li.append(g)
li.append(b)
li.sort(reverse=True)
r=li[0]
g=li[1]
b=li[2]

while n>=ir*r:
        if r == 1:


            while n>=ig*g:
                if g==1:
                    i=ig=n
                    if (n - (ir * r + ig * g)) / b >= 0:
                        if (n-(ir*r+ig*g))%b==0:

                             ans=ans+n
                else:
                    i = ig = n
                    if (n - (ir * r + ig * g)) / b >= 0:
                        if (n - (ir * r + ig * g)) % b == 0:
                            ans = ans + 1
                    ig = ig + 1
            ir = n
            ig=0
            ans=ans*n

        else:
            pass

print(ans)

Submission status: Time Limit Exceeded

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

cnt = 0
for i in range(n//r+1):
  if n-r*i >= 0:
    for j in range((n-r*i)//g+1):
      if (n-r*i-g*j)>=0 and (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())

cnt = 0
for i in range(n//r+1):
  for j in range((n-r*i)//g+1):
    if (n-r*i-g*j)>=0 and (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
ir=0
ig=0
ib=0
li=[]
li.append(r)
li.append(g)
li.append(b)
li.sort(reverse=True)
r=li[0]
g=li[1]
b=li[2]

while n>=ir*r:
        if r == 1:


            while n>=ig*g:
                if g==1:
                    i=ig=n
                    if (n - (ir * r + ig * g)) / b >= 0:
                        if (n-(ir*r+ig*g))%b==0:

                             ans=ans+n
                else:
                    i = ig = n
                    if (n - (ir * r + ig * g)) / b >= 0:
                        if (n - (ir * r + ig * g)) % b == 0:
                            ans = ans + 1
                    ig = ig + 1
            ir = n
            ig=0
            ans=ans*n

        else:
            while n >= ig * g:
                if (n - (ir * r + ig * g)) / b >= 0:
                    if (n - (ir * r + ig * g)) % b == 0:
                        ans = ans + 1
                ig = ig + 1
            ir = ir + 1
            ig = 0

print(ans)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
ans=0
ir=0
ig=0
ib=0
li=[]
li.append(r)
li.append(g)
li.append(b)
li.sort(reverse=True)
r=li[0]
g=li[1]
b=li[2]

while n>=ir*r:
        if r == 1:


            while n>=ig*g:
                if (n - (ir * r + ig * g)) / b >= 0:
                    if (n-(ir*r+ig*g))%b==0:

                         ans=ans+1
                ig = ig + 1
            ir = n
            ig=0
            ans=ans*n

        else:
            while n >= ig * g:
                if (n - (ir * r + ig * g)) / b >= 0:
                    if (n - (ir * r + ig * g)) % b == 0:
                        ans = ans + 1
                ig = ig + 1
            ir = ir + 1
            ig = 0

print(ans)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
ans=0
ir=0
ig=0
ib=0
li=[]
li.append(r)
li.append(g)
li.append(b)
li.sort(reverse=True)
r=li[0]
g=li[1]
b=li[2]

while n>=ir*r:
        if r == 1:


            while n>=ig*g:
                if (n - (ir * r + ig * g)) / b >= 0:
                    if (n-(ir*r+ig*g))%b==0:

                         ans=ans+1
                ig = ig + 1
            ir = ir + 1
            
            ig=0
            ans=ans*n
            
        else:
            while n >= ig * g:
                if (n - (ir * r + ig * g)) / b >= 0:
                    if (n - (ir * r + ig * g)) % b == 0:
                        ans = ans + 1
                ig = ig + 1
            ir = ir + 1
            ig = 0

print(ans)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
ans=0
ir=0
ig=0
ib=0
li=[]
li.append(r)
li.append(g)
li.append(b)
li.sort(reverse=True)
r=li[0]
g=li[1]
b=li[2]

while n>=ir*r:
        if r == 1:


            while n>=ig*g:
                if (n - (ir * r + ig * g)) / b >= 0:
                    if (n-(ir*r+ig*g))%b==0:

                         ans=ans+1
                ig = ig + 1
            ir = ir + 1
            ig=0
            ans=ans*n
        else:
            while n >= ig * g:
                if (n - (ir * r + ig * g)) / b >= 0:
                    if (n - (ir * r + ig * g)) % b == 0:
                        ans = ans + 1
                ig = ig + 1
            ir = ir + 1
            ig = 0

print(ans)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
ans=0
ir=0
ig=0
ib=0
li=[]
li.append(r)
li.append(g)
li.append(b)
li.sort(reverse=True)
r=li[0]
g=li[1]
b=li[2]
while n>=ir*r:

    while n>=ig*g:
        if (n - (ir * r + ig * g)) / b >= 0:
            if (n-(ir*r+ig*g))%b==0:

                 ans=ans+1
        ig = ig + 1
    ir = ir + 1
    ig=0
print(ans)

Submission status: Time Limit Exceeded

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

while n>=ir*r:

    while n>=ig*g:
        if (n - (ir * r + ig * g)) / b >= 0:
            if (n-(ir*r+ig*g))%b==0:

                 ans=ans+1
        ig = ig + 1
    ir = ir + 1
    ig=0
print(ans)

Submission status: Time Limit Exceeded

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

while n>=ir*r:

    while n>=ig*g:

        if (n-(ir*r+ig*g))%b==0:
            if (n-(ir*r+ig*g))/b>=0:
                 ans=ans+1
        ig = ig + 1
    ir = ir + 1
    ig=0
print(ans)

Submission status: Time Limit Exceeded

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

while n>=ir*r:

    while n>=ig*g:

        while n>=ib*b:
            
            if n==(ir*r+ig*g+ib*b):
                ans=ans+1

            ib = ib + 1
        ig = ig + 1
        ib=0
    ir = ir + 1
    ig=0
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):
    if N < R*r:
        break
    for g in range(N+1):
        if N < R*r + G*g:
            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+1):
    for g in range(N+1):
        s = N - R*r - G*g
        if s >= 0 and s % B == 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys,random
try: sys.stdin = open('in.in','r')
except: pass

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

ans = 0
for r in range(0,N+1):
	if r*R > N: break
	for b in range(0,N+1):
		if b*B + r*R > N: break
		if (N-b*B-r*R)%G != 0: continue
		ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

for g in range(N + 1):
    for r in range(N + 1):
        if r * R + g * G > N:
            break
        b = (N - (r * R + g * G)) / B
        if b.is_integer():
            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-r*i)//g+1):
        if (n-r*i-g*j) < 0:
            break
        if (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 i in range(3001):
    for j in range(3001):
        if (n-r*i-g*j) < 0:
            break
        if (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())
sorted_rgb = sorted((r,g,b))
import itertools
cnt = 0
for x in itertools.product([i for i in range(int(n/sorted_rgb[0])+1)],[j for j in range(int(n/sorted_rgb[1])+1)]):
    if ((n-x[0]*sorted_rgb[0]-x[1]*sorted_rgb[1])%sorted_rgb[2] == 0)&((n-x[0]*sorted_rgb[0]-x[1]*sorted_rgb[1])>=0):
        cnt +=1
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a,b,c,n = tuple(int(x) for x in raw_input().split(' '))

ans = 0
for i in xrange(0, n/a+1):
  for j in xrange(0, n/b+1):
    k = (n - i*a - j*b)/c
    #print i,j,k,i*a+j*b+k*c
    if i*a+j*b+k*c == n and k >= 0:
      ans += 1
print ans

Submission status: Time Limit Exceeded

Solution code:
# sys.stdin.readline()
import sys
input = sys.stdin.readline

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding:utf-8 -*-
r,g,b,n=map(int,input().split(" "))
count=0
r1=n//r
for i in range(0,r1+1):
    g1=(n-i*r)//g+1
    for j in range(0,g1):
        b1=(n-i*r-j*g)//b+1 
        for z in range(0,b1):
            if n-i*r-j*g-z*b==0:
                count=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 x in range(N+1):
    for y in range(N-x+1):
        '''
        if (N - x*R - y*G ) % B == 0:
            cnt += 1
        '''
        for z in range(N-x-y+1):
            if N == x*R + y*G + z*B:
                cnt += 1


print(cnt)

Submission status: Time Limit Exceeded

Solution code:
rgbn=list(map(int,input().split()))
r=rgbn[0]
g=rgbn[1]
b=rgbn[2]
n=rgbn[3]
c=0
for i in range(n+1):
    for j in range(n+1):
        if n-i*r-j*g>=0 and (n-i*r-j*g)%b==0:
            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(N+1):
    for j in range(N+1):
        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())
count=0
for r in range(N//R+1):  
  y=N-r*R
  for g in range(y//G+1):
    n=N-R*r-G*g
    if n>=0 and n%B==0:
      b=int(n/B)
      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+1):
	for j in range (N+1):
		z=N-(R*i+G*j)
		if z>=0 and z%B==0:
			ans+=1
print(ans)

Submission status: Time Limit Exceeded

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

ans_count = 0

for red in range(int(N/R)+1):
  for green in range(int((N-red*R)/G)+1):
    for blue in range(int((N-red*R-green*G)/B)+1):
      if red*R + green*G + blue*B == N:
        ans_count += 1

print(ans_count)

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):
        V = N - (r * R + g * G)
        if V >= 0 and V % 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 // G) + 1):
        V = r * R + g * G 
        if N >= V and (N - V) % 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 // G) + 1):
        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:
from sys import exit

R, G, B, N = map(int, 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 < 0:
			break
		if (N - r * R - g * G) % B == 0:
			count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
from sys import exit

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

count = 0

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

print(count)

Submission status: Time Limit Exceeded

Solution code:
from sys import exit

R, G, B, N = map(int, 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 and N - r * R - g * G >= 0:
			count += 1

print(count)

Submission status: Time Limit Exceeded

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

n = int(N / min(R,G,B))
ans_count = 0

for red in range(int(N/R)+1):
  for green in range(int(N/G)+1):
    for blue in range(int(N/B)+1):
      if red*R + green*G + blue*B == N:
        ans_count += 1

print(ans_count)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = list(map(int, input().split()))
result = 0
for g in range(3000):
  for b in range(3000):
    tmp = N - g * G - b * B
    if (tmp >= 0) and (tmp % R == 0):
      result += 1
print(result)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,n=map(int,input().split())
sum_rg=[]
for r in range(n+1):
	for g in range(n+1):
		Rr,Gg=R*r,G*g
		if Rr+Gg>n:
			break
		else:
			sum_rg.append(n-Rr-Gg)
count=0
for i in sum_rg:
	if not i%B:
		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 // R + 1):
    tmp = N - i * R
    for j in range(N // G + 1):
        tmp2 = tmp - j * G
        if tmp2 < 0:
            continue
        if tmp2 % 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(N // R + 1):
    for j in range(N // G + 1):
        tmp = N - i * R - j * G
        if tmp < 0:
            continue
        if tmp % B == 0:
            count += 1

print(count)