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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
A = list(map(int, input().split()))
N = A.pop(3)
A.sort()
R = A[2]
G = A[1]
B = A[0]
ans = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        now = N - r*R - g*G
        if  now >= 0 and now % B == 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# def gcd(a_gcd, b_gcd):
#     while b_gcd != 0:
#         a_gcd, b_gcd = b_gcd, a_gcd % b_gcd
#     return a_gcd
#
#
# def lcm(a_lcm, b_lcm):
#     return a_lcm * b // gcd(a_lcm, b_lcm)
#
#
# def max_sum(N_max_sum, a_max_sum):
#     dp = [0] * (N_max_sum + 1)
#     for i in range(N_max_sum):
#         dp[i + 1] = max(dp[i], dp[i] + a_max_sum[i])
#     return dp[N]
#
#
# def knapsack(N_knapsack, W, weight, value):
#     inf = float("inf")
#     dp = [[-inf for _ in range(W+1)] for j in range(N_knapsack + 1)]
#     for i in range(W+1):
#         dp[0][i] = 0
#
#     for i in range(N_knapsack):
#         for w in range(W+1):
#             if weight[i] <= w:
#                 dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
#             else:
#                 dp[i+1][w] = dp[i][w]
#     return dp[N_knapsack][W]


# # s = input()
# # N = int(input())
# N, K = map(int, input().split())
# # b = list(map(int, input().split()))
# # c = [list(map(int, input().split())) for _ in range(N)]
#
#
#
# print(N-K+1)

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

if B > R:
    B, R = R, B
if B > G:
    B, G = G, B

for r_i in range(N + 1):
    if r_i * R > N:
        break
    for g_i in range(N + 1):
        if r_i * R + g_i * G > N:
            break
        if (N - (r_i * R + g_i * G)) % B == 0:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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


print(count)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(R, G, B, N):
    ans = 0
    r = -R
    for i in range(N//R + 1):
        r += R
        g = -G
        for j in range((N-r)//G + 1):
            g += G
            b = -B
            for k in range((N-r-g)//B + 1):
                b += B
                if r + g + b == N:
                    ans += 1

    return ans


def main():
    R, G, B, N = read_int_n()
    # A = [read_int_n() for _ in range(N)]
    print(slv(R, G, B, N))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
r, g, b, n = map(int, input().split())
import math
ans = 0
for i in range(math.ceil(n / r)+1):
    for j in range(math.ceil(n / 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:
#aR + bG + cB = N なる(a,b,c)の組
ans = 0
R,G,B,N = map(int,input().split())
for i in range(3001):
    if i*R > N:
        break
    for j in range(3001):
        if i*R + j*G > N:
            break
        if (N- (i*R + j*G)) % B == 0:
            ans += 1 
print(str(ans))

Submission status: Time Limit Exceeded

Solution code:
r, b, g, n=map(int, input().split())  #複数数値入力

import numpy as np

arr =  np.array([r, b, g])
arr.sort()

comb = 0
for i in range(int(n / arr[2])+1):
#     print(i)
    for j in range(int((n - i*arr[2]) / arr[1])+1):
#         print(j)
        if (n - i*arr[2] - j*arr[1]) % arr[0] == 0:
#             print(i, j)
            comb += 1
print(comb)

Submission status: Time Limit Exceeded

Solution code:
r,g,y,n=map(int,input().split())
a=0
b=0
c=0
count=0


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

    m=n

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

N1 = n // l[2]
N2 = n // l[1]
N3 = n // l[0]

cnt = 0

for i in range(N1+1):
    for j in range(N2+1):
        for k in range(N3+1):
            if i*l[2] + j*l[1]+ k*l[0]==n:
                cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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))%b==0:
            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 ri in range(int(n/r)+1):
    for gi in range(int(n/g)+1):
        if (n-ri*r-gi*g)%b==0 and (n-ri*r-gi*g)/b>=0:
            count+=1

print(count)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

sum=0
for x in range(0,1+(3000//r)):
    for y in range(0,1+(3000-x*r)//g):
        if r*x+g*y<=n and (n-r*x-g*y)%b==0:
            sum+=1
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):
    r=R*i
    if r>n:
        break
    for j in range(n+1):
        g=G*j
        if r+g>n:
            break
        b=n-r-g
        if b%B==0:
            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(N//R+1):
    for g in range(N//G+1):
        if N-r*R-g*G >= 0 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 i in range(3001):
    for j in range(3001):
        k = n - (i*r + j*g)
        if k >= 0 and k%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 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())
color = [R, G, B]
color.sort(reverse = True)
maxr = N // color[0]
maxg = N // color[1]
count = 0
for i in range(maxr+1):
    for j in range(maxg+1):
        nokori = N - i * color[0] - j * color[1]
        amari = nokori % color[2]
        if nokori >= 0 and amari == 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

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

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

print(count)

Submission status: Time Limit Exceeded

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

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

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):
        remain = N - r*R - g*G
        if remain >= 0 and remain % B == 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7


R, G, B, N = MAP()
count = 0
for i in range(N+1):
	for j in range(int((N-i*R)//G)+1):
		r = i
		g = j
		b = int(max(0, (N - r*R - g*G))/B)
		# print(r, g, b)
		if R*r + G*g + B*b == N:
			count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:


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

ans=0
for j in range(N+1):
        for i in range(N+1):
                #下の計算で２つの色で変えるボールの全探索
                #足りない数があるとすれば、N-i*R-G*Bであり、
                if(N-i*R-G*j>=0 and (N-i*R-G*j)%B==0):
                        ans+=1

print(ans)

Submission status: Time Limit Exceeded

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

rgb = [R, G, B]
rgb.sort(reverse=True)
R, G, B = rgb

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
R, G, B, N = map(int, input().split())

output = 0
for g in range(N // G + 1):
    for b in range(N // B + 1):
        if (N - g*G - b*B) % R == 0:
            if N >= g*G + b*B:
                output += 1
            else:
                break
print(output)

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

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int, input().split())
count = 0
for r in range(0,N+1) :
    rn = r * R
    if rn == N :
        count += 1
    elif rn > N :
        pass
    else :
        for g in range(0, N+1) :
            gn = g * G
            if rn + gn == N :
                count += 1
            elif gn > N :
                pass
            else :
                for b in range(0, N + 1):
                    bn = b * B
                    if rn + gn + bn == N:
                        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 0 <= (N - R * r - G * g) and (N - R * r - G * g) % B == 0:
            count += 1

print(count)

Submission status: Time Limit Exceeded

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

cnt = 0

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

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int,input().split())
count = 0
for i in range (N//R+1):
    for j in range (N//G+1):
        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:
from sys import stdin
import math
import fractions
from collections import deque

INF = 10 ** 10

R, G, B, N = [int(x) for x in stdin.readline().rstrip().split()]

cnt = 0
RN = N // R + 1
GN = N // G + 1
BN = N // B + 1

for i in range(RN):
    for j in range(GN):
        for k in range(BN):
            num = R * i + G * j + B * k
            if num > N:
                break
            if num == 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(3001):
    for j in range(3001):
        if n - r * i - g * j < 0:
            break
        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())
ans=0

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

cnt = 0

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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):
        k = N - R*i- G*j
        if k<0 or k % B != 0 : continue
        k /= B
        cnt += 1
            
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict, deque, Counter
def inpl(): return list(map(int, input().split()))

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

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]
res = 0
r = 0
while R * r <= N:
    b = 0
    while B * b <= N - R * r:
        if (N - R * r -B * b) % G == 0:
            res += 1
        b += 1
    r += 1
print(res)

Submission status: Time Limit Exceeded

Solution code:
def gcd(a_gcd, b_gcd):
    while b_gcd != 0:
        a_gcd, b_gcd = b_gcd, a_gcd % b_gcd
    return a_gcd


def lcm(a_lcm, b_lcm):
    return a_lcm * b // gcd(a_lcm, b_lcm)


def max_sum(N_max_sum, a_max_sum):
    dp = [0] * (N_max_sum + 1)
    for i in range(N_max_sum):
        dp[i + 1] = max(dp[i], dp[i] + a_max_sum[i])
    return dp[N]


def knapsack(N_knapsack, W, weight, value):
    inf = float("inf")
    dp = [[-inf for _ in range(W+1)] for j in range(N_knapsack + 1)]
    for i in range(W+1):
        dp[0][i] = 0

    for i in range(N_knapsack):
        for w in range(W+1):
            if weight[i] <= w:
                dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
            else:
                dp[i+1][w] = dp[i][w]
    return dp[N_knapsack][W]


# # s = input()
# # N = int(input())
# N, K = map(int, input().split())
# # b = list(map(int, input().split()))
# # c = [list(map(int, input().split())) for _ in range(N)]
#
#
#
# print(N-K+1)

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

for r_i in range(N + 1):
    if r_i * R > N:
        break
    for g_i in range(N + 1):
        if r_i * R + g_i * G > N:
            break
        if (N - (r_i * R + g_i * G)) % B == 0:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsm = lambda: map(str, sys.stdin.readline().split())

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

sum=0
for x in range(0,3001):
    for y in range(0,1+(3000-x*r)//g):
        if r*x+g*y<=n and (n-r*x-g*y)%b==0:
            sum+=1
print(sum)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

from collections import defaultdict

R, G, B, N = map(int, input().rstrip().split(' '))
A = [R, G, B]

dp = defaultdict(lambda: defaultdict(lambda: -1))
def rec(i, n):
    if dp[i][n] != -1:
        return dp[i][n]
    if n == 0:
        return 1
    if i > 2:
        return 0
        
    #print(i, n)
        
    temp = 0
    for j in range(n // A[i] + 1):
        temp += rec(i + 1, n - j * A[i])
        
    dp[i][n] = temp
    
    return temp
    
print(rec(0, N))

Submission status: Time Limit Exceeded

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

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 (N - R * r - G * g) % B == 0 and 0 <= (N - R * r - G * g) // B <= N // B:
			ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

input = sys.stdin.readline
r, g, b, n = map(int, input().split())
cnt = 0
for i in range(int(n/r)+1):
    for j in range(int(n/g)+1):
        tmp = r*i + g*j
        if tmp > n:
            break
        else:
            tmp = n - tmp 
        if tmp%b == 0:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
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 (N-R*r-G*g) >= 0 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())
rr=0
ans=0
while rr*r<=n:
    gg=0
    while rr*r+gg*g<=n:
        if (n-(rr*r+gg*g))%b == 0:
            ans+=1
        gg+=1
    rr+=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 i*r+j*g<=n and (n-(i*r+j*g))%b ==0:
            ans +=1
print(ans)

Submission status: Time Limit Exceeded

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

# max num
n_r = N // R
n_g = N // G
n_b = N // B
ans = 0
for i in range(n_r + 1):
    for j in range(n_g + 1):
        num = N - R * i - G * j
        if num >= 0 and num % B == 0:
            # print(i, j, num // B)
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

import math

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

ans = 0
for i in range(math.ceil(n / r)+1):
    for j in range(math.ceil(n / g)+1):
        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())
a=0
for i in range(0,n+1,r):
    for j in range(0,n+1,g):
        k=n-i-j
        if k>=0 and not k%b:
            a+=1
print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7


R, G, B, N = MAP()
count = 0
for i in range(N+1):
	for j in range(N+1):
		r = i
		g = j
		b = int(max(0, (N - r*R - g*G))/B)
		# print(r, g, b)
		if R*r + G*g + B*b == N:
			count += 1
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = list(map(int,input().split(" ")))
c = 0
rl = n//r + 1
bl = n//b + 1


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

count = 0
for i in range(0, N+1, R):
    for j in range(0, N+1, G):
        if (N-i-j) % B == 0 and N >= (i+j):
            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(3000 // R + 1):
    for j in range(3000 // G + 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())
ans=0
for i in range(3001):
    for j in range(3001):
        if 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:
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
r,g,b,n=IL()
ans=0
for i in range(0,n//r+1):
    for j in range(0,n//g+1):
        if (n-i*r-j*g)%b==0 and n-i*r-j*g>=0:
            ans+=1
            
print(ans)

Submission status: Time Limit Exceeded

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

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

print(score)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env pypy3

import math, itertools, operator
from math import *
from math import factorial as fact
from itertools import permutations, combinations
from functools import reduce
from statistics import mean, median, median_low, median_high, mode
# Before Python 3.5
from fractions import gcd

#import numpy
#import scipy, scipy.special
#from sympy import isprime, nextprime
#from sympy.ntheory import factorint

inf = float('inf')

def lcm(a, b):
    return a * b // gcd(a,b)

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))

################################################################################


R, G, B, N = input_ints()

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

print(cnt)