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 = (int(i) for i in input().split())
maxr = N // R
maxg = N // G
maxb = N // B
result = 0

for i in range(maxr + 1):
    for j in range(maxg + 1):
        for k in range(maxb + 1):
            if N == R * i  + G * j  + B * k :
                result += 1 

print(result)

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
ans=0
for r in range(r_max+1):
    res=N-r*R
    for g in range(g_max+1):
        x=(res-G*g)
        if x>=0 and x%B==0:
            ans+=1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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 / 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:
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/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:
a,b,c,d=list(map(int,input().split()))
e=[a,b,c]
w,r,t=e[0],e[1],e[2]
u=0
for i in range(d//a+1):
    y=d-(a*i)
    for o in range(y+1):
        x=y-(b*o)
        if y==0 or x==0 or x%c==0 and x>=0:
            u+=1
print(u)

Submission status: Time Limit Exceeded

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

while r * R <= N:
  g = g0
  Nr = N
  Nr -= r * R
#  print("Nr:", Nr, "r:", r)
  while g * G <= Nr:
    Ng = Nr
    Ng -= g * G
#    print("Ng:", Ng, "g:", g)
    if Ng % B == 0:
      b = (Ng/B)
      ans += 1
#      print("ANS:", ans, "r:", r, "g:", g, "b:", b)
    g += 1
  r += 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 + 1):
    for y in range(n + 1):
        w = r * x + g * y
        if w > n:
            break
        for z in range(n + 1):
            w = r * x + g * y + b * z
            if w > n:
                break
            if w == n:
                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-x+1):
        z=(n-r*x-g*y)//b
        if 0<=z<=3000 and r*x+g*y+z*b==n: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(0,int(N/R)+1):
  for j in range(0,int(N/G)+1):
    if i*R+j*G<=N and (N-i*R-j*G)%B == 0:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

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

for i in range(N+1):
    if RGB[0] * i <= N:
        R.append(RGB[0] * i)
        
for i in range(N+1):
    if RGB[1] * i <= N:
        G.append(RGB[1] * i)
        
for i in range(N+1):
    if RGB[2] * i <= N:
        B.append(RGB[2] * i)

for i in R:
    for j in G:
        for k in B:
            if i + j + k == N:
                ans.append(((i, j, k)))
                
print(len(ans))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N=map(int, input().split())
cnt=0
import math
r_range=math.ceil(N/R)+1
g_range=math.ceil(N/G)+1
for r in range(r_range):
    red = r*R
    for g in range(g_range):
        rem = (N-red-g*G)
        mod = rem % B
        if rem>=0 and mod == 0:
            cnt+=1
print(cnt)

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:
        break
    elif r*R == N:
        count += 1
        break
    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

print(count)

Submission status: Time Limit Exceeded

Solution code:
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=[]
for i in range(blim+1):
    blist.append(i*b)


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
rgb=[r,g,b]
rgb.sort()
r=rgb[0]
g=rgb[1]
b=rgb[2]
ans=0
for i in range(n//b+1):
    for j in range(n//g+1):
        if g*j+b*i==n:
            ans=ans+1
        elif g*j+b*i>n:
            break
        elif (n-(g*j+b*i))%r==0:
            ans=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+1):
    for y in range(n+1):
        for z in range(n+1):
            w = r*x + g*y + b*z
            if w>n:
                break
            if w == n:
                ans+=1
print(ans)

Submission status: Time Limit Exceeded

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

li = [r,g,b]
x = max([r,g,b])
li.remove(x)
y = max(li)
li.remove(y)
z = li[0]
ans = 0
for i in range(math.ceil(n/x)+1):
  for j in range(math.ceil((n-x*i)/y)+1):
    if (n - x*i - y*j)%z == 0 and n - x*i - y*j >= 0:
      ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# from time import perf_counter


def main():
    r, g, b, n = list(map(int, input().split()))
    count = 0
    x1, x2, x3 = sorted([r, g, b], reverse=True)
    # print(x1, x2, x3)
    for i in range(n // x1 + 1):
        for j in range((n - i) // x2 + 1):
            for k in range((n - i - j) // x3 + 1):
                # print(f'{r}*{i} + {g}*{j} + {b}*{k} = {r*i+g*j+k+b*k}')
                if x1 * i + x2 * j + x3 * k == n:
                    count += 1

    print(count)


if __name__ == '__main__':
    # s = perf_counter()
    main()
    # e = perf_counter()
    # print('process:', e - s)

Submission status: Time Limit Exceeded

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

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

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

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

r = N // R
g = N // G
b = N // B

c = 0
for i in range(r + 1):
    for j in range(g + 1):
        t = N - i * R - j * G
        if t == 0:
            c += 1
            continue
            
        if t < 0:
            continue
            
        if t % B == 0:
            c += 1
                
print(c)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N=(int(x) for x in input().split())
count=0
R1=N//R
R2=N//G
R3=N//B
for r in range(R1+1):
    n=N
    n=n-r*R
    if n==0:
        count=count+1
    if n>0:
        for g in range(R2+1):
            n=N-r*R
            n=n-g*G
            if n==0:
                count=count+1
            if n>0:
                for b in range(R3+1):
                    n=N-r*R-g*G
                    n=n-b*B
                    if n==0:
                        count=count+1

print(count)

Submission status: Time Limit Exceeded

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

count = 0
x = range(math.ceil(n/r) + 1)
y = range(math.ceil(n/g) + 1)
z = range(math.ceil(n/b) + 1)
for xx in x:
    for yy in y:
        for zz in z:
            sum = r * xx + g * yy + b * zz
            if sum == n:
                count += 1

print(count)

Submission status: Time Limit Exceeded

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

C=sorted([R,G,B])

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

Submission status: Time Limit Exceeded

Solution code:
# R*r + G*g + B*b == N の数
R, G, B, N = map(int, input().split())
R, G, B = list(sorted([R, G, B], reverse=True))
ans = 0
for r in range(N + 1):
    for g in range(N + 1):
        if (N - (r * R + g * G)) % B != 0:
            continue
        b = (N - (r * R + g * G))/B
        if b < 0:
            break
        if r * R + g * G + b * B == N:
            ans += 1
        elif r * R + g * G + b * B > N:
            break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,n = list(map(int,input().split()))
cnt=0
a,b,c=sorted([a,b,c])
for i in range(1+n//c):
    m=n-c*i
   # print(n,i)
    for j in range(1+n//b):
        l=m-b*j
  #      print(n,j)
        for k in range(1+n//a):
            o=l-a*k
 #           print(n,k)
            if o==0:
                cnt+=1
#                print(i,j,k)
print(cnt)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

print(count)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = [int(x) for x  in input().split()]
ar = [R,G,B]
ar.sort()
ar.reverse()
R,G,B = [int(x) for x in ar]

count = 0

n = 0



for i in range(0,N+1):
    if(R * i > N):
        break    
    for j in range(0,N-(R*i)+1):
        if((R*i + G*j )> N):
            break
        for k in range(0,N-(R*i+G*j)+1):
            n = R * i + G*j +B *k
            
            if(n == N):
                count += 1
                n = 0
                break

            if(n > N):
                break
                
                
    
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)]
bList = [i*B for i in range(int(N/B)+1)]


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

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int, input().split())
rgb_list = [r,g,b]
rgb_list.sort()
r,g,b = rgb_list
max_y = n//g
max_z = n//b

count = 0
for y in range(max_y + 1):
    for z in range(max_z + 1):
        x_before = n - g*y - b*z
        if( (x_before / r) < 0 ):
            break
        if( (x_before % r == 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+1):
    for g in range(N+1-r):
        if (N-R*r-G*g) % B ==0 and -1 < N-R*r-G*g :
            count += 1
print(count)

Submission status: Time Limit Exceeded

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

count = 0
r,g,b = sorted([r, g, b], reverse=True)

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

print(count)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N=map(int, input().split())
count=0
for p1 in range(0,N+1,R):
    for p2 in range(0,N-p1+1,G):
        rR = p1
        gG = p2
        bB = N-p1-p2
        if rR%R==0 and gG%G==0 and bB%B==0:
            count+=1
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = list(map(int, input().split()))
cnt = 0
i=0
while r*i <= n:
  j=0
  while (r*i+g*j) <= n:
    if ( (n-(r*i+g*j)) % b ) == 0 :
      cnt += 1
    j += 1
  i += 1
print(str(cnt))

Submission status: Time Limit Exceeded

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

for h in range( n // r + 1):
    for i in range (n//g + 1):        
        if( (n - (h*r + i*g) ) % b == 0) and (h*r + i*g) <= n   :
            cnt += 1
                
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
num_list = [R,G,B]
num_list = sorted(num_list,reverse = True)
ans = 0
for i in range(0,int(N/num_list[0])+1):
  for j in range(0,int(N/num_list[1])+1):
    if i*num_list[0]+j*num_list[1]<=N and (N-i*num_list[0]-j*num_list[1])%num_list[2] == 0:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
a, b, c, n = map(int, input().split())
aa =[a,b,c]
r = max(aa)
b = min(aa)
g = int(np.median(aa))
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/g)+1):
        if (n - r*i_r - g*i_g)<0:continue
        if 0==((n - r*i_r - g*i_g)%b):

            count +=1

print(count)

Submission status: Time Limit Exceeded

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

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10000)

def sub_sum(nums, total, calc_total):
    if calc_total == total:
        global g_cnt
        g_cnt += 1
    if calc_total > total:
        return

    for i in range(len(nums)):
        sub_sum(nums[i:], total, calc_total + nums[i])

R, G, B, N = map(int, input().split())
g_cnt = 0
sub_sum([R, G, B], N, 0)
print (g_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//g + 1):
        tmp = r*i+g*j
        k = (n - (tmp))//b
        if k < 0:
            continue
        if (tmp+b*k == n):
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
# R*r + G*g + B*b == N の数
R, G, B, N = map(int, input().split())
# R, G, B = list(sorted([R, G, B]))
ans = 0
for r in range(N+1):
    for g in range(N + 1):
        if (N - (r * R + g * G)) % B != 0:
            continue
        b = (N - (r * R + g * G))/B
        if b < 0:
            break
        if r * R + g * G + b * B == N:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

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

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
in_r, in_g, in_b, n = map(int, input().split())

ans = 0

in_list= [in_r,in_g,in_b]
sorted_list = sorted(in_list)

r = sorted_list[-1]
g = sorted_list[-2]
b = sorted_list[-3]

max_r = n // r

for i in range(max_r+1):
    tmp = n - (r * i)
    max_g = tmp // g
    after_r = tmp
    for j in range(max_g+1):
        tmp = after_r
        tmp = tmp - (g * j)
        max_b = tmp // b
        after_g = tmp
        if tmp%b == 0:
            ans = 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//b+1):
    for j in range(n//g+1):
        if g*j+b*i==n:
            ans=ans+1
        elif g*j+b*i>n:
            break
        elif (n-(g*j+b*i))%r==0:
            ans=ans+1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
count = 0
for a in range(N+1):
    for b in range(N-a+1):
        c = N-a-b
        if a%R == 0 and b%G == 0 and c%B == 0:
            count +=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
if __name__ == "__main__":
  s = input().split(" ")
  R = int(s[0])
  G = int(s[1])
  B = int(s[2])
  N = int(s[3])
  
  count = 0
  for i in range(N+1):
    sumR = R * i
    if sumR == N:
      count += 1
      break
    elif sumR > N:
      break
    else:
      for j in range(N+1):
        sumG = G * j
        if sumR + sumG == N:
          count += 1
          break
        elif sumR + sumG > N:
          break
        else:
          for k in range(N+1):
            sumB = B * k
            if sumR + sumG + sumB == N:
              count += 1
              break
            elif sumR + sumG + sumB > N:
              break
  print(count)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
counter = 0
# R, G, B = sorted([R, G, B])
r = 0
while r * R <= N:
  g = 0
  while g * G <= N:
    b = (N - r*R - g*G)/B 
    if b < 0:
      break
    elif b == int(b):
      counter += 1
    g += 1
  r += 1
print(counter)

Submission status: Time Limit Exceeded

Solution code:
import os, sys, re, math

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

ret = 0
ri = 0
while (ri * r <= n):
    rg = 0
    while (rg * g <= n - ri * r):
        if ((n - ri *r - rg * g) % b == 0):
            ret += 1    
        rg += 1
    ri += 1

print(ret)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

nr_max = n // r
ng_max = n // g

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

print(count)

Submission status: Time Limit Exceeded

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

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())

    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    tokens = lines[0].split(" ")
    r = int(tokens[0])
    g = int(tokens[1])
    b = int(tokens[2])
    n = int(tokens[3])

    return (r, g, b, n)


def solve(r, g, b, n):

    result = 0
    for i in range(n+1):
        j = 0
        k = 0
        x = n - i*r
        if x == 0:
            result = result + 1
            continue
        if x < 0:
            break

        for j in range(x+1):
            k = 0
            y = x - j*g
            if y == 0:
                result = result + 1
                continue
            if y < 0:
                break

            for k in range(y+1):
                z = y - k*b
                if z == 0:
                    result = result + 1
                if z < 0:
                    break

    return result


def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

sys.setrecursionlimit(100000)

def f(a):
  global R,G,B,N,ans,Rm,Gm,Bm

  for b in range(N-R*a+1):
    cmod=(N-R*a-G*b)%B
    c=(N-R*a-G*b)//B
    if cmod==0 and  c>=0:
      ans+=1
    elif c<0:
      break

  if a>0:
    f(a-1)


R,G,B,N=list(map(int,input().split(" ")))
Rm=N//R
Gm=N//G
Bm=N//B

ans=0

f(Rm)

print(ans)

Submission status: Time Limit Exceeded

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

total = N
ans = 0
remain = 0

for r  in range (N//R +1):
    for g in range(N//G +1):
            remain = (N - r*R - g*G ) // B
            if N == abs(remain) * B +r*R + g*G:
                  ans+=1
            elif N < abs(remain) * B +r*R + g*G:
                  break
print(ans)

Submission status: Time Limit Exceeded

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

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

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N=[0,0,0]
N[0],N[1],N[2],n=map(int,input().split())
N.sort(reverse=True)
cnt=0
for x in range(n//N[0]+1):
    for y in range((n-x*N[0])//N[1]+1):
        if (n-x*N[0]-y*N[1])%N[2]==0 and (n-x*N[0]-y*N[1])/N[2]>=0:
            cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

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

count=0
for p1 in range(N+1):
    for p2 in range(p1+1):
        rR = p2
        gG = p1-p2
        bB = N-p1
        if rR%R==0 and gG%G==0 and bB%B==0:
            count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
g = 0
c = 0
r,g,b = 0,0,0
for i in range(0,N//R+1):
    sr = i*R
    for j in range(0,(N-i*R)//G+1):
        sg = j*G
        if sr + sg <= N:
            sb = N - sr - sg
            if sb % B == 0:
                c += 1
print(c)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# R*r + G*g + B*b == N の数
R, G, B, N = map(int, input().split())
# R, G, B = list(sorted([R, G, B]))
ans = 0
for r in range(N+1):
    for g in range(N + 1):
        if (N - (r * R + g * G)) % B != 0:
            continue
        b = (N - (r * R + g * G))/B
        if b < 0:
            continue
        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())

if r >= g and g >= b:
    pass
elif r >= b and b >= g:
    temp = g
    g = b
    b = temp
else:
    temp = r
    r = g
    g = temp

rg = {}
ri = 0
while ri <= n:
    gi = 0
    while gi <= n - ri:
        if (n - ri - gi) % b == 0:
            total = rg.get(ri + gi, 0)
            rg[ri + gi] = total + 1
        else:
            pass
        gi += g
    ri += r

bi = 0
result = 0

while bi <= n:
    total = rg.get(n - bi, 0)
    result += total
    bi += b

print(result)

Submission status: Time Limit Exceeded

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

S = min(R, G, B)
L = max(R, G, B)
M = R + G + B - S - L

cnt = 0
sum = 0
for i in range(N // L + 1)[::-1]:
    for j in range(N // M + 1)[::-1]:
        for k in range(N // S + 1):
            sum = N - i * L - j * M - k * S  
            if sum == 0:
                cnt += 1
            if sum < 0:
                break
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//g + 1):
        k = (n - (r*i+j*g))//b
        if k < 0:
            continue
        if (r*i+g*j+b*k == n):
            count += 1
print(count)

Submission status: Time Limit Exceeded

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

cnt = 0

_R = N//R
_G = N//G
_B = N//B

for i in range(_R+1):
    for j in range(_G+1):
        if  i*R + j*G > N:
            break
        for k in range(_B+1):
            if i*R + j*G + k*B == N:
                cnt += 1
            elif i*R + j*G + k*B > N:
                break
print(cnt)

Submission status: Time Limit Exceeded

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

count = 0
r,g,b = sorted([r, g, b], reverse=True)

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

print(count)

Submission status: Time Limit Exceeded

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

R,G,B,N =[int(x) for x in input().split()]
a = 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:
            a += 1
                       
           

print(a)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
g = 0
c = 0
r,g,b = 0,0,0
for i in range(0,N//R+1):
    sr = i*R
    for j in range(0,N//G+1):
        sg = j*G
        if sr + sg <= N:
            sb = N - sr - sg
            if sb % B == 0:
                c += 1
print(c)

Submission status: Time Limit Exceeded

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

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

print(count)

Submission status: Time Limit Exceeded

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

c = []
ans = 0
c.append(int(n/r))
c.append(int(n/b))
c.append(int(n/g))

for i in range(c[0]+1):
  for j in range(c[1]+1):
    for k in range(c[2]+1):
      if (i*r + j*b + k*g) == n:
        ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N=map(int, input().split())
result = []
import math
for r in range(math.ceil(N/R)+1):
    for g in range(math.ceil(N/G)+1):
        b = (N-r*R-g*G) // B
        mod = (N-r*R-g*G) % B
        if b>=0 and mod == 0:
            result.append((r,g,b))
print(len(result))

Submission status: Time Limit Exceeded

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


#def cnt2(sum, a, b):

cnt = 0
for rr in range(n // r + 1):
  sum = r * rr
  rest = n - sum
  #cnt += cnt2(rest, g, b)
  for gg in range(rest // g + 1):
    sum = r * rr + g * gg
    rest = n - sum
    if rest < 0:
      break
    if rest % b == 0:
      bb = (n-sum) // b
      cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import sys

sys.setrecursionlimit(100000)

def f(a):
  global R,G,B,N,ans,Rm,Gm,Bm

  for b in range(N-R*a+1):
    cmod=(N-R*a-G*b)%B
    c=(N-R*a-G*b)//B
    if cmod==0 and  c>=0:
      ans+=1

  if a>0:
    f(a-1)


R,G,B,N=list(map(int,input().split(" ")))
Rm=N//R
Gm=N//G
Bm=N//B

ans=0

f(Rm)

print(ans)

Submission status: Time Limit Exceeded

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

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(-(-N//R)+1):
    for g in range(((N-R*r)//G)+1):
        for b in range((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:
def combinations(R, G, B, N):
    R, G, B, N = int(R), int(G), int(B), int(N)
    number_combos = 0
    
    for x in range(N + 1):
        N_modified_x = N - R * x
        for y in range(N_modified_x + 1):
            N_modified_y = N_modified_x - G * y
            for z in range(N_modified_y + 1):
                if B * z == N_modified_y:
                    number_combos += 1
    return number_combos

print(combinations(13, 1, 4, 3000))

Submission status: Time Limit Exceeded

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

cnt = 0

_R = N//R
_G = N//G
_B = N//B

for i in range(_R+1):
    for j in range(_G+1):
        for k in range(_B+1):
            if i*R + j*G + k*B == N:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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