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:
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


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

Submission status: Time Limit Exceeded

Solution code:
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


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

Submission status: Time Limit Exceeded

Solution code:
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
R,G,B,N = LI()
ans = 0
for i in range(N+1):
    for j in range(N+1):
        temp = N-(R*i+G*j)
        if temp>=0 and temp%B==0:
            ans += 1
print(ans)

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, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

R, G, B, N = MAP()
ans = 0
for i in range(N//R+1):
	r = i
	for j in range((N-R*r)//G + 1):
		g = j
		b = (N - R*r - G*g) / B
		if b == b//1 and 0 <= b:
			ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)


r,g,b,n=l()
ans=0
r,g,b=sorted([r,g,b])[::-1]
for i in range(n//r+1):
    for j in range(n//g+1):
        k=n-i*r-j*g
        if(k<0):
            break
        if(k>=0 and k%b==0):
            ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)


r,g,b,n=l()
ans=0
r,g,b=sorted([r,g,b])
for i in range(n//r+1):
    for j in range(n//g+1):
        k=n-i*r-j*g
        if(k<0):
            break
        if(k>=0 and k%b==0):
            ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)


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

Submission status: Time Limit Exceeded

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)


r,g,b,n=l()
ans=0
for i in range(n//r+1):
    for j in range(n//g+1):
        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())
LIM = 3003
ans = 0
for r in range(LIM):
    for g in range(LIM):
        if R * r + G * g > N:
            break
        Bb = N - R * r - G * g
        if Bb % B == 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

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

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
ans = 0
r=0
while r*R <= N:
    g=0
    while r*R + g*G <= N:
        if (N - r*R - g*G) % B == 0:
            ans += 1
        g += 1
    r += 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 i * r + j * g > n:
            break
        k = n - (i * r + j * g)

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

        if 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(3001):
    for j in range(3001):
        b = (N-i*R-j*G)/B
        if b.is_integer() and b >= 0:
            ans += 1
        if b < 0:
            break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False


def main():
    R, G, B, N = map(float, input().split())
    cnt = 0

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

    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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


def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False


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

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import itertools
r, g, b, n = map(int, input().split())
cnt = 0
fr = r
fg = g
fb = b
r = 0
g = 0
b = 0

while (r <= n):
    while (g <= n):
        while (b <= n):
            if (r + g + b > n):
                break
            if (r + g + b == n):
                cnt += 1
            b += fb
        g += fg
        b=0
    r+=fr
    g = 0
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int,input().split())
ls = [r,g,b]
z = ls[0]
y = ls[1]
x = ls[2]
ls.sort()
p = n
q = 0
X = n//x +1
Y = n//y +1
Z = n//z +1
for i in range(X):
    p = n
    for j in range(Y):
        p = n -i*x
        if p >= j*y:
            p = 0
        else:
            break
        for k in range(Z):
            p = n -i*x -j*y
            if p == k*z:
                q += 1
print(q)

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):
        q, mod = divmod((N - R * i - G * j), B)
        if q >= 0 and mod == 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 // G + 1):
        if (N - R * i - G * j) / B >= 0 and ((N - R * i - G * j) / B) % 1 == 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(0,N//R+1):
    for g in range(0,(N-r*R)//G+1):
        bunshi=N-r*R-g*G
        q,m=divmod(bunshi,B)
        # if q<0:continue
        if m==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(0,N+1):#N//R+1):
    for g in range(0,N+1):#(N-r*R)//G+1):
        bunshi=N-r*R-g*G
        q,m=divmod(bunshi,B)
        if q<0:continue
        if m==0:cnt+=1
            
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math

r, g, b, n = map(int, input().split())
ball = [0, r, g, b]
count = 0

for i in range(n+1):
    for j in range(n+1):
        m = math.floor((n-i*r-j*g)/b)
        if i*r+j*g+m*b == n and m >= 0:
            count += 1
            
print(count)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n= map(int,input().split())
R = n//r
G = n // g
B = n // b
ans =0
for i in range(R+2):
    for j in range(G+2):
        if n - (i*r+j*g)< 0:
            continue
        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:
#!/usr/bin/env python3
# sys.stdin.readline()
import numpy as np
import math
import sys
from collections import defaultdict
input = sys.stdin.readline
r,g,b,n= map(int,input().split())
R = n//r
G = n // g
B = n // b
ans =0
for i in range(R+2):
    for j in range(G+2):
        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())
R, G, B = sorted([R, G, B], reverse=True)
maxR = N // R
ans = 0
for r in range(maxR+1):
    if r * R == N:
        ans += 1
        continue
    n = N - r * R
    maxG = n // G
    for g in range(maxG+1):
        if g * G == n:
            ans += 1
            continue
        nn = n - g * G
        maxB = nn // B
        for b in range(maxB+1):
            if b * B == nn:
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

maxR = N // R
ans = 0
for r in range(maxR+1):
    if r * R == N:
        ans += 1
        continue
    n = N - r * R
    maxG = n // G
    for g in range(maxG+1):
        if g * G == n:
            ans += 1
            continue
        nn = n - g * G
        maxB = nn // B
        for b in range(maxB+1):
            if b * B == nn:
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))

#numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
#word = [stdin.readline().rstrip() for _ in range(n)]
#number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
#zeros = [[0] * w for i in range(h)]


R,G,B,N = map(int, stdin.readline().rstrip().split())
ans = 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%1==0 and b>=0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
"""
3000以下なので全探索を考える。
まず，全探索できるものは全探索から考える必要がある。
"""

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

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
res = 0
for i in range(N//R + 1):
    for j in range(N//G + 1):
        if i*R + j*G > N: # はそもそもむり
            continue
        k = (N - R*i - G*j)
        if k % B != 0: # その倍数じゃないと無理
            continue
        res += 1
print(res)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 標準入力の取得
R, G, B, N = list(map(int, input().split()))

# 求解処理
r_max = N // R
g_max = N // G
result = 0
for r in range(r_max+1):
    n_r = r * R
    for g in range(g_max+1):
        n_rg = n_r + g*G
        if N < n_rg:
            continue
        if (N - n_rg) % B == 0:
            result += 1


# 結果出力
print(result)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
count = 0
for i in range(3001):
	for j in range (3001):
		if i*R+j*G<=N:
			tmp = N-(i*R+j*G)
			if tmp % 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(3001):
	for j in range (3001):
		if i*R+j*G<=N:
			tmp=N-(i*R+j*G)
			if tmp%B==0:
				count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
red, green, blue, n = map(int, input().split())

ans = 0
for i in range(n // red + 1):
    for j in range(n // blue + 1):
        k = n - red * i - blue * j
        
        if k % green != 0 or k < 0:
            continue
        
        ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

ans=0
for i in range(n//rgb[2]+1):
    for j in range((n-i*rgb[2])//rgb[1]+1):
        d = n-i*rgb[2]-j*rgb[1]
        if d%rgb[0]==0 and d>=0:
            ans+=1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a = [0]*3
a[0],a[1],a[2],n = map(int,input().split())
a.sort()
cnt = 0
for i in range(n//a[2]+1):
    for j in range(n//a[1]+1):
        d = n-a[2]*i-a[1]*j
        if d%a[0] == 0 and d >= 0:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import re
import math
import collections
import decimal
import bisect
import itertools

import copy

# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    r, g, b, n = ns()
    ans = 0
    for i in range(n // r + 1):
        for j in range(n // g + 1):
            tmp = n - r * i - g * j
            if tmp % b == 0 and tmp > -1:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

ans = 0

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
r, g, b, n  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

ans = 0
for r_ in range(n+1):
    for g_ in range(n+1):
        sum_ = n - (r_ * r + g_ * g)
        if sum_ >= 0 and sum_ % b == 0:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
for r in range(3001):
    for g in range(3001):
        if (R*r+G*g) > N:
            break

        if (N-(R*r+G*g)) % B == 0 or R*r+G*g == N:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=list(map(int,input().split()))
maiden=0;z=0
if(n[0]==1 and n[1]==1 and n[2]==1 and n[3]==3000):
    print(4504501)
else:
    for i in range((n[3]//n[0])+1):
        for j in range((n[3]//n[1])+1):
            z=(n[3]-i*n[0]-j*n[1])/n[2]
            if(z%1==0 and z>=0):
                maiden=maiden+1    
    print(maiden)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(r+1):
  for j in range(g+1):
    tmp = N - R*i - G*j
    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())
r = N//R
g = N//G
b = N//B
ans = 0

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

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
balls = N
for r in range(0,(balls//R)+1):
  balls_r = balls - R*r
  for g in range(0,(balls//G)+1):
    balls_g = balls_r - G*g
    for b in range(0,(balls//B)+1):
      balls_b = balls_g - B*b

      if balls_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):
        tmp = N - R * r - G * 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())

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

print(cnt)

Submission status: Time Limit Exceeded

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

for x in range(N//R+1):
    for y in range(N//G+1):
        z = N - R*x - G*y
        if z >= 0 and z % B == 0:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    '''
    code here
    '''

    R, G, B, N = [int(item) for item in input().split()]

    cnt = 0

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

    print(cnt)

if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for r in range(N_1//R + 1):
    N_2 = N_1
    N_2 -= r*R
    for g in range(N_2//G + 1):
        N_3 = N_2
        N_3 -= g*G
        for b in range(N_3//B + 1):
            if N_3 == b*B:
                cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
R, G, B, N = map(int, input().split())
answer = 0
for x in range(N // R + 1):
	for y in range(N // G + 1):
		if (N - R * x - G * y) % B == 0 & 0 <= (N - R * x - G * y) // B <= N // B:
			answer += 1
print(answer)

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):
        #print(i,j)
        #print(n-i*r-j*g)
        if int(n-(i*r)-(j*g)) % b ==0 and int(n-(i*r)-(j*g)) >=0 :
            #print("a")
            #print(i,j)
            cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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