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

Solution (Python):
r,g,b,n = map(int, input().split())
dp = [[0] * 3001, [0] * 3001, [0] * 3001]
dp[0][0] = 1
dp[1][0] = 1
dp[2][0] = 1
for x in range(1, (n+1)):
    if x - r >= 0:
        dp[0][x] = dp[0][x-r]
for x in range(1, (n+1)):
    dp[1][x] = dp[0][x]
    if x-g >= 0:
        dp[1][x] += dp[1][x-g]
for x in range(1, (n+1)):
    dp[2][x] = dp[1][x]
    if x-b >= 0:
        dp[2][x] += dp[2][x-b]
print(dp[2][n])

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

dp = [0 for i in range(n+1)]
dp[0] = 1

for i in range(r, n+1, r):
    dp[i] = 1

for i in range(g, n+1):
    dp[i] += dp[i-g]

for i in range(b, n+1):
    dp[i] += dp[i-b]

print(dp[n])

Solution (Python):

import sys


def kumiawase(x, y, n):
    p = max(x, y)
    q = min(x, y)

    kumi_kosu = 0

    for i in range(n // p + 1):
        if (n - p * i) % q == 0:
            kumi_kosu = kumi_kosu + 1
            

    return kumi_kosu


p = [int(i) for i in input().split()]


r,g,b = sorted(p[0:3], reverse=True)
n = p[3]



kumi_kosu_2 = 0




for i in range(n // r + 1):
    kumi_kosu_2 = kumi_kosu_2 + kumiawase(g, b, n - r * i)
    

print(kumi_kosu_2)

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

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

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

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

Solution (Python):



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)%B == 0:
            a += 1
                       
           

print(a)

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

maxr=N//R
maxg=N//G

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

Solution (Python):
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)

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

def f(a, b):
    sho, amari = int(a/b), a%b
    return sho, amari


def ans(l, m, s):
    cnt = 0

    R_s, R_a = f(N, l)

    for i in range(R_s + 1):
        x = R_a + i * l 
        G_s, G_a = f(x, m)
        for j in range(G_s + 1):
            y = G_a + j * m 
            if y % s == 0:
                cnt += 1
    return cnt

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

cnt = ans(li[0], li[1], li[2])

print(cnt)

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

ans = 0

num = [r,g,b]

num.sort()



for i in range(n+1):
    if i * num[2] > n:
        break
    for j in range(n+1):
        
            
        
        if (n - i*num[2] - j*num[1]) < 0:
            break
        if (n - i*num[2] - j*num[1]) % num[0] == 0:
            ans = ans + 1

print(ans)

Solution (Python):
R,G,B,N = [int(x) for x in input().split()]
cnt = 0
for i in range(N//R+1):
    for j in range((N-R*i)//G+1):
        if((N-R*i-G*j)%B==0):
            cnt+=1

print(cnt)

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

print(cnt)

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

count = 0

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

print(count)

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

print(cnt)

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

Solution (Python):
from sys import stdin
import math
input=input=stdin.readline().rstrip().split()
for i in range(len(input)):
  input[i]=int(input[i])

output=0
R=input[0]
G=input[1]
B=input[2]
N=input[3]
for r in range(math.floor(N/R)+1):
    for g in range(math.floor(N/G)+1):
        
        
        
        b=N-(r*R+g*G)
        
        
        if b<0:
            break
        if b % B == 0:
            
            output+=1
print(output)

Solution (Python):
def gcd(n,m):
    while n > 0:
        a = n
        n = m % n
        m = a
    return m

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

C = G * B // gcd(G,B)

s = 0
b = 0
while b <= N:
    bb = b
    while bb <= N:
        if (N - bb) % B == 0:
            s += (N - bb) // C + 1
            bb = N + 1
        else:
            bb += G
    b += R

print(s)

Solution (Python):
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 (n-r*i-g*j)<0:
            continue
        elif (n-r*i-g*j)%b==0:
            res+=1
            
print(res)

Solution (Python):
a,b,c,d= input().split()
N = int(d)
R= int(a)
G = int(b)
B = int(c)

max_r = N // R
count = 0
for i in range(max_r+1):
 rest_n_r = N - R*i
 max_g = rest_n_r // G
 for j in range(max_g+1):
  rest_n_r_g = rest_n_r - G*j
  mod = rest_n_r_g % B
  if(mod == 0):
   count += 1

print(count)

Solution (Python):
r,g,b,n=map(int,input().split())
m=[r,g,b]
m.sort(reverse=1)
r,g,b=m[0],m[1],m[2]
ans=0
if m==[1,1,1]:
  print((n+2)*(n+1)//2)
else:
  for i in range(n+1):
    if r*i>n:
      break
    for j in range(n+1):
      if r*i+g*j>n:
        break
      if (n-r*i-g*j)%b==0:
        ans+=1
  print(ans)

Solution (Python):
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

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


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

print(count)

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




def count_r_ball_patterns(R, N_a):
    return 1 if N_a % R == 0 else 0


def count_rg_ball_patterns(R, G, B, N_b):
    max_g = N_b // G
    result = 0
    for g in range(max_g + 1):
        result = result + count_r_ball_patterns(R, N_b - G * g)
    return result


def count_rgb_ball_patterns(R, G, B, N):
    
    R, G, B = sorted([R, G, B])
    max_b = N // B
    result = 0
    for b in range(max_b + 1):
        result = result + count_rg_ball_patterns(R, G, B, N - B * b)
    return result


if __name__ == "__main__":
    print(count_rgb_ball_patterns(R, G, B, N))

Solution (Python):
import math
r,g,b,n = [int(u) for u in input().split(" ")]
i = 0
for ir in range(math.floor(n/r)+1):
  if ir*r==n:
    i+=1
    break
  elif ir*r>n:
    break
  for ig in range(math.floor(n/g)+1):
    y = n - (ir*r+ig*g)
    if y<0:
      break
    if y%b==0:
      
      i+=1
      continue
print(i)

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

ans = 0

for r in range(0, N+1, R):    
    for g in range(0, N+1-r, G):
            
        if (N - r - g) % B == 0:
            ans += 1
            
                
print(ans)

Solution (Python):
R,G,B,N =  map(int, input().split())
ans = 0
for n in range(N+1):
  s = n * R 
  if(s > N):
    break
  for n2 in range(N+1):
    s2 = s + n2 * G
    if(s2 > N):
      break
    if((N-s2) % B == 0):
      ans += 1
print(ans)

Solution (Python):
import operator as op
from io import StringIO
from collections import *
from functools import *
from fractions import gcd
import sys


def main(inputs):
    
    
    xs = list(map(int, next(inputs).split()))
    y = reduce(gcd, xs)
    r, g, b, n = map(op.floordiv, xs, [y]*4)
    ans = 0
    for i in range(1 + (n // r)):
        n_r = n - r*i
        for j in range(1 + (n_r // g)):
            if (n_r - g*j) % b == 0:
                
                ans += 1
                pass
            pass
        pass
    return ans


def gen_inputs(str_=None):
    inputs = StringIO(str_) if str_ else sys.stdin
    while True:
        a = inputs.readline().rstrip()
        yield a
        pass
    pass


if __name__ == "__main__":
    print(main(gen_inputs()))
    pass

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

Solution (Python):
rn,gn,bn,n=map(int,input().split())
nn=sorted([rn,gn,bn]) 
c=0
for r in range(1+n//nn[0]):
    rt=n-nn[0]*r
    for g in range(1+rt//nn[1]):
        gt=rt-nn[1]*g
        if gt%nn[2]==0:
            c+=1
print(c)

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

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

print(cnt)

Solution (Python):
r,g,b,n=list(map(int,input().split()))
count=0
for i in range(n//r+1):
  tn = n
  tn = tn - r*i
  
  if tn < 0: break
  if tn == 0:
    
    count+=1
    continue
  for j in range(tn//g+1):
    tnn = tn
    tnn -= g*j
    if tnn < 0: break
    if tnn==0:
      
      count+=1
      continue
    if tnn%b == 0:
      count+=1
      

print(count)

Solution (Python):

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

ans = 0
rmax = n//r
gmax = n//g
for i in range(rmax+1):
    for j in range(gmax+1):
        rest = n-r*i-g*j
        if rest<0: break
        if rest%b==0: ans += 1

print(ans)

Solution (Python):


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

for i in range(n + 1):
    for j in range(n + 1):
        total = n - r * i - g * j
        if total < 0:
            break
        if total % b == 0:
            count += 1

print(count)

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

Solution (Python):
from statistics import median
R,G,B,N = map(int,input().split())
count = 0
n_max = max(R,G,B)
n_mid = median([R,G,B])
n_min = min(R,G,B)
for i in range(N//n_max + 1):
  x = N - i*n_max
  for j in range(x//n_mid + 1):
    y = x - j*n_mid
    if y % n_min == 0:
      count += 1
print(count)

Solution (Python):
import math
input = input().split()
r = int(input[0])
g = int(input[1])
b = int(input[2])
N = int(input[3])

count = 0


for x in range(math.ceil(N/r+0.0001)):
    for y in range(math.ceil((N-x*r)/g + 0.0001)):
        
        if  (N - x*r - y*g) % b == 0:
            count +=1

print(count)

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

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

result = 0
max_r = n // r

for i in range(max_r + 1):
    max_g = (n - i * r) // g
    for j in range(max_g + 1):
        if (n - i * r - j * g ) % b == 0:
            result += 1
print(result)

Solution (Python):
r,g,b,n = map(int,input().split())
numR = n//r
numG = n//g
numB = n//b
c = 0
for i in range(0,n+1,r):
    for j in range(0,n+1,g):
        x = n-(i+j)
        if x%b ==0 and (i+j)<=n:
            c+=1

print(c)

Solution (Python):
R, G, B, N = map(int, input().split())
ans = 0
BN = []
for b in range(N+1):
    BN.append(N - (b * B))
BN = set(BN)
for r in range(N+1):
    for g in range(N+1):
        if r * R + g * G in BN:
            ans += 1
print(ans)

Solution (Python):


import math

line=input().split(" ")
n=int(line[3])
r=int(line[0])
g=int(line[1])
b=int(line[2])
nline=sorted([r,g,b])
x=int(nline[2])
y=int(nline[1])
z=int(nline[0])

answers=0



for i in range(math.ceil(n/x)+1):
    a=i
    if z!=1:
        for j in range(math.ceil((n-a*x)/y)+1):
            b=j
            c=(n-a*x-b*y)/z
            if c>=0 and (n-a*x-b*y)%z==0:
                answers+=1
                
    else:
        if n-a*x>=0:
            if n-a*x==0:
                answers+=1
                
            elif (n-a*x)%y!=0:
                answers+=math.ceil((n-a*x)/y)
                
            else:
                answers+=(math.ceil((n-a*x)/y)+1)
                
            

print(answers)

Solution (Python):
from fractions import gcd
from functools import reduce

nums = list(map(int, input().split()))
N = nums[3]
R, G, B = sorted(nums[:3])

d = reduce(gcd, [R, G, B])


R, G, B, N = R//d, G//d, B//d, N//d

count = 0
for b in range(N//B + 1):
    M = N - B * b
    for g in range(M//G + 1):
        L = M - G * g
        if L % R == 0:
            count += 1

print(count)

Solution (Python):
r,g,b,n=list(map(int,input().split()))
count=0
for i in range(3001):
  for j in range(3001):
    a=n-(i*r+j*g)
    if(a<0):
      break
    if( a%b == 0):
      count+=1
print(count)

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

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

Solution (Python):


def solve():
    R, G, B, N = map(int, input().split())
    dp = [[0 for __ in range(8)] for _ in range(6002)]
    for n in range(1,N+1):
        if n == R:
            dp[R][4] += 1
        if n == G:
            dp[G][2] += 1
        if n == B:
            dp[B][1] += 1

        dp[n][1] += dp[n-B][1]
        dp[n][2] += dp[n-G][2]
        dp[n][3] += (dp[n-G][1] + dp[n-G][3] + dp[n-B][2] + dp[n-B][3])//2
        dp[n][4] += dp[n-R][4]
        dp[n][5] += (dp[n-R][1] + dp[n-R][5] + dp[n-B][4] + dp[n-B][5])//2
        dp[n][6] += (dp[n-R][2] + dp[n-R][6] + dp[n-G][4] + dp[n-G][6])//2
        dp[n][7] += (dp[n-R][3] + dp[n-R][7] + dp[n-G][5] + dp[n-G][7] + dp[n-B][6] + dp[n-B][7])//3
    return str(sum(dp[N]))

if __name__ == '__main__':
    print(solve())

Solution (Python):
a,b,c,n=map(int,input().split( ))

s=0
for i in range(n//a+1):
    for j in range((n-a*i)//b+1):
        ck=(n-a*i-b*j)
        if ck%c==0 and ck//c>=0:
            s+=1
        

print(s)

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

cnt = 0
for i in range(n//r+1):
  n_r = i*r
  if n_r > n:
    break
  for j in range(n//g+1):
    n_rg = j*g + n_r
    if n_rg > n:
      break
    if (n-n_rg)%b == 0:
      cnt += 1
        
print(cnt)

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

Solution (Python):

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

ans = 0
rmax = n//r
for i in range(rmax+1):
    rest = n-r*i
    gmax = rest//g
    for j in range(gmax+1):
        rest = n-r*i-g*j
        if rest%b==0: ans += 1

print(ans)

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

dp =[[1, 1, 1]]
for x in range(n):
    dp.append([0, 0, 0])

for i in range(1, n + 1):
    for j in range(3):
        dp[i][j] = 0
        for q in range(j, 3):
            if i - l[q] >= 0:
                dp[i][j] = dp[i][j] + dp[i - l[q]][q]

print(dp[n][0])

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

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

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

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

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)

Solution (Python):
s = input()
answer = 0
s =s.split(" ")
R = int(s[0])
G = int(s[1])
B = int(s[2])
N = int(s[3])

def turukame(g,b,n):
    ans = 0
    for j in range(n//g+1):
        if (n-g*j) % b == 0:
            ans = ans + 1
    return ans


for i in range(N // R+1):
    answer = answer + turukame(G,B,N-R*i)

print(answer)

Solution (Python):

import itertools
from collections import Counter
from collections import defaultdict
import bisect

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

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


if __name__ == '__main__':
    main()

Solution (Python):
def solve():
    R, G, B, N = map(int, input().split())
    ans = 0
    for r in range(N + 1):
        cnt1 = R * r
        if cnt1 > N:
            break
        for g in range(N + 1):
            cnt2 = cnt1 + G * g
            if cnt2 > N:
                break
            if (N - cnt2) % B == 0:
                ans += 1
    print(ans)
solve()

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

x = 0
for i in range(N//R+1):
    k = N - (i*R)
    for j in range(k//G+1):
        l = k - (j*G)
        if l % B == 0:
            x += 1
        else:
            x += 0

print(x)

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

count = 0

len_r = N // R + 2
for ix in range(len_r):
    len_g = (N - (R * ix)) // G + 2
    for iy in range(len_g):
        t = N - (R * ix + G * iy)
        if t >= 0 and t % B == 0:
            count += 1
print(count)

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

cnt = 0

a = 3000//R


for i in range(0,a+1):
    b = (3000-R*i)//G
    for j in range(0,b + 1):
        if(R*i+G*j)<=N and (N-R*i - G*j )%B==0:

            cnt += 1
            
        
        
        
        
        


print(cnt)

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

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

cnt = 0
r, g, b = 0, 0, 0

while r*R <= N:
    tank = N - r*R
    while True:
        if divmod(tank, B)[1] == 0:
            cnt += 1
        tank -= G
        if tank < 0:
            break
    r += 1

print(cnt)

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

Solution (Python):
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-r*i)/g) + 1):

        if (n - (r*i + g*j))%b==0 and n - (r*i + g*j) >= 0:
            cnt += 1
print(cnt)

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

Solution (Python):
r, g, b, n= [int(_) for _ in input().split()]
c = [r, g, b]
c.sort(reverse = True)
ans = 0
for i in range(n // c[0] + 1):
    for j in range((n-i*c[0]) // c[1] + 1):
        if (n-i*c[0]-j*c[1]) % c[2] == 0:
            ans += 1
print(ans)

Solution (Python):
l = raw_input().split()
M = [0]*3
M[0] = int(l[0])
M[1] = int(l[1])
M[2] = int(l[2])
N = int(l[3])
M.sort()



count = 0

for i in range(N / M[2] + 1):
    remain1 = N - i * M[2]
 
    for j in range(remain1 / M[1] + 1):
        remain2 = remain1 - j * M[1]

        if remain2 % M[0] == 0:

            count += 1

print(count)

Solution (Python):
def main():
    R, G, B, N = [int(n) for n in input().split()]
    res = 0
    for r in range(3001):
        for g in range(3001):
            RG = R *r + G * g
            if RG > N:
                break
            elif (N - RG) % B == 0:
                res += 1
    print(res)

main()

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

Q_B = N // B
for i in range(0,Q_B+1):
    Q_G = (N - B * i) // G
    for j in range(0,Q_G+1):
        if ((N - B * i - G * j) % R == 0):
            count += 1
print(count)

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

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

buyR = int(N/R)
N1 = 0
count = 0


for i in range(buyR+1):
    N1 = N - i*R
    for j in range(int(N1/G)+1):
        if N1 - j*G >= 0:
            if (N1-j*G)%B == 0:
                count += 1

print(count)

Solution (Python):


















import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque

from itertools import product

from itertools import permutations

from itertools import combinations
from bisect import bisect_left, bisect_right


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

R, G, B, N = s_inpl()

ans = 0

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

print(ans)

Solution (Python):
R, B, G, N = map(int,input().split())
 
 
cnt = 0
ball = 0
a = sorted([R,G,B])
for r in range(N//a[0]+1):
    ball = r*a[0]
    for b in range((N-ball)//a[1]+1):
        if N-ball >= 0 and (N-ball-b*a[1])%a[2] == 0:
            cnt += 1
 
print(cnt)

Solution (Python):
import sys
import random
import itertools
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
r,g,b,n = map(int,input().split())
ans = 0
for i in range(n+1):
    noko = n-r*i
    if noko < 0:
        break
    for j in range(n+1):
        noko = n-r*i
        noko = noko - g*j
        if noko < 0:
            break
        if noko % b == 0:
            ans += 1
print(ans)

Solution (Python):
R,G,B,n = map(int,input().split())
ans = 0
for r in range(n+1):
    for g in range(n+1):
        if r*R + g*G <= n:
            p = n - r*R - g*G
            if p%B == 0:
                ans += 1
                



print(ans)

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

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

org_list = [R, G, B]
org_list.sort()
first_num = org_list[2]
second_num = org_list[1]
third_num = org_list[0]

count = 0

for i in range(N // first_num + 1):
  for j in range((N-i*first_num) // second_num + 1):
    if (N - i*first_num - j*second_num) % third_num == 0:
      count += 1
 
print(count)

Solution (Python):
R, G, B, N = map(int, input().split())
ans = 0
zi = N // B
ans = 0
for b in range(zi + 1):
    y = (N - B * b)
    gi = y // G
    for g in range(gi + 1):
        x = y - G * g
        if x % R == 0:
            ans += 1
print(ans)

Solution (Python):
import collections as c
ip = lambda : map(int, input().split())


r,g,b,n = ip()
ans = 0

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

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

m1 = max(r, g, b)
m3 = min(r, g, b)
m2 = r+g+b-(m1+m3)

l1 = [m1*i for i in range(0, n//m1+1)]
cnt = 0

i = 0
while i*m1 <= n:
    j = 0
    while i*m1 + j*m2 <= n:
        if (n - (i*m1 + j*m2))%m3 == 0:
            cnt += 1
        j += 1
    i += 1
    
print(cnt)

Solution (Python):
from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]


def solve(input_string):
    r, g, b, n = makeMultiInteger(input_string[0])
    c = 0
    nr = int(n/r)+1
    ng = int(n/g)+1
    nb = int(n/b)+1
    
    
    """
    for i in range(nr):
        _sum = i*r
        if _sum == n:
            c += 1
            break
        for j in range(ng):
            _sum = j*g+i*r
            if _sum == n:
                c += 1
                break
            for k in range(nb):
                _sum = i*r + j*g + k*b
                
                if _sum == n:
                    c += 1
                    break
    """
    for i in range(nr):
        _sum = i*r
        if _sum > n:
            break
        for j in range(ng):
            _sum = j*g+i*r
            if _sum > n:
                break
            rg_sum = j*g+i*r
            if (n - rg_sum) % b == 0:
                c += 1
            """
            for k in range(nb):
                _sum = i*r + j*g + k*b
                
                if _sum == n:
                    c += 1
                    break
            """
    return c


def main():
    input_lines = stdin.readlines()
    answer = solve(input_lines)
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):
r,g,b,n=map(int,input().split())
lista = [r,g,b]
lista.sort()
l = lista[-1]
m = lista[-2]
s = lista[-3]
ans = 0
for i in range((n//l)+1):
    for j in range(((n-i*l)//m)+1):
        if (n-i*l-j*m)%s==0:
            ans+=1
print(ans)

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

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

Solution (Python):

import numpy as np
R, G, B, N= map(int, input().split())

A=[R,G,B]
A.sort()
A=np.array(A)

count=0

shou_max = N//A[2]
warukazu2 = np.arange(0, shou_max+1)
A3 = N-warukazu2*A[2]

for x in A3:
    shou_max = x//A[1]
    warukazu1 = np.arange(0, shou_max+1)
    A2 = x-warukazu1*A[1]
    
    count+=np.sum(A2%A[0]==0)




print(count)

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

Solution (Python):
r, g, b, n = input().split()

r = int(r)
g = int(g)
b = int(b)
n = int(n)

max_r = n // r

count = 0

for ir in range(max_r + 1):
    remaining = n - r * ir
    max_g = remaining // g
    for ig in range(max_g + 1):
        remaining = n - r * ir - g * ig
        if remaining % b == 0:
            count += 1

print(count)

Solution (Python):



def main():
    R, G, B, N = map(int, input().split())
    ans = 0
    rgb_list = [R, G, B]
    rgb_list.sort()
    for r in range(int(N/rgb_list[-1])+1):
        tempN = N - r * rgb_list[-1]
        
        if tempN == 0:
            ans += 1
            
            continue
        for g in range(int(N/rgb_list[-2])+1):
            
            tempN2 = tempN - g * rgb_list[-2]
            if tempN2 == 0:
                ans += 1
                continue
            elif tempN2 < 0:
                break
            else:
                if tempN2 % rgb_list[0] == 0:
                    ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

R, G, B, N = map(int, input().split())
dp = [0] * (6001)
dp[R] = 1
for i in range(N+1):
    dp[i + R] += dp[i]

dp[G] += 1
for i in range(N+1):
    dp[i + G] += dp[i]

dp[B] += 1
for i in range(N+1):
    dp[i + B] += dp[i]

print(dp[N])

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

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

print(cnt)

Solution (Python):
R, G, B, N = (int(i) for i in input().split())
numofpattern = 0
for i in range(1+(N // R)):
    for j in range(1+((N - i * R) // G)):
        if (N-i*R-j*G) % B == 0:
            numofpattern += 1
print("{}".format(numofpattern))

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

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

cnt = 0

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

print(cnt)

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

Solution (Python):
R, G, B, N = map(int, input().split())
number = [R, G, B]
number = sorted(number)
M = N // number[2]
ans = 0

if number[2] == 1:
    print((N+2)*(N+1)//2)
else:
    for i in range(0, M+1):
        value1 = i * number[2]
        L = (N-value1) // number[1]
        for j in range(0, L+1):
            value2 = j * number[1]
            if N-value1-value2 >= 0 and (N-value1-value2) % number[0] == 0:
                ans += 1
                continue
    
    print(ans)

Solution (Python):
r, g, b, n = map(int, input().split())
dp = [0 for _ in range(n + 1)]
dp[0] = 1
for d in [r, g, b]:
    for i in range(d, n + 1):
        dp[i] = dp[i] + dp[i - d]
print(dp[n])

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

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

total = 0

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

        if (N - r * R - g * G) >= 0 and (N - r * R - g * G) % B == 0:
            
            total += 1

print(total)

Solution (Python):
import math


def solve():
    count = 0
    R, G, B, N = map(int, input().split())
    
    for r in range(math.floor(N / R) + 1):
        
        for g in range(math.floor(((N - (R * r)) / G)) + 1):
            if (N - (R * r) - (G * g)) % B == 0:
                
                
                count += 1
    print(count)


if __name__ == '__main__':
    solve()

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

counter = 0
for i in range(int(n/r) + 1):
  for j  in range(int((n - r * i) / g) + 1):
    if (n - r * i - g * j) % b == 0:
      counter +=1

print(counter)

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

r, g, b = sorted([r, g, b])

ans = 0
divb = int(n / b)
for i in range(divb+1):
    remain_n1 = n - b * i
    divg = int(remain_n1 / g)
    for j in range(divg+1):
        remain_n2 = remain_n1 - g * j
        if remain_n2 % r == 0:
            ans += 1

print(ans)