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: Accepted

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

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

Submission status: Accepted

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

x = 0

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

Submission status: Accepted

Solution code:
R, G, B, N = map(int, input().split())
count = 0
rgb = sorted([R, G, B], reverse=True)
if False:
    count = 0
else:
    for i in range(N+1):
        for j in range(N+1):
            tmp = N - (rgb[0] * i + rgb[1] * j)
            if 0 > tmp:
                break
            if tmp % rgb[2] == 0:
                count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

sum = 0
for i in range(n // l[2] + 1):
    for j in range((n - l[2] * i) // l[1] + 1):
        if ((n - l[2] * i - l[1] * j) % l[0] == 0):
            sum += 1

print(sum)

Submission status: Accepted

Solution code:
R,G,B,N=map(int,input().split())
ls=(sorted([R,G,B]))
mx,md,sm=ls[2],ls[1],ls[0]
count=0

biggest_box_max=N//mx
for i in range(biggest_box_max+1):
    rest_N=N-mx*i
    middle_box_max=rest_N//md
    for j in range(middle_box_max+1):
        rest_rest_N=rest_N-md*j
        if rest_rest_N%sm==0:
            count+=1
        
print(count)

Submission status: Accepted

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

c = 0
for n in range(N+1):
    for nn in range(n+1):
        if nn % R == 0 and (n - nn) % G == 0 and (N - n) % B == 0:
            c += 1
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
input = sys.stdin.readline
 
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
def main():
	R, G, B, N = map(int, input().split(" "))
	
	ans = 0
	for i in range(N+1):
		r = i * R
		for j in range(N+1):
			g = j * G
			if N - r - g < 0:
				continue
			if (N - r - g) % B != 0:
				continue
			#k = (N - r - g) // B
			#print("{} {} {}".format(i, j, k))
			ans += 1
			

	print(ans)

	
	
if __name__ == "__main__":
	main()

Submission status: Accepted

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

Max = max(R, G, B)
Min = min(R, G, B)
Mid = R+G+B - Max - Min
ans = 0

for i in range((N // Max) +1):
    rem1 = N - (i*Max)
    for j in range((rem1 // Mid) +1):
        rem2 = rem1 - (j*Mid)
        if rem2 % Min == 0:
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline

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

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

print(count)

Submission status: Accepted

Solution code:
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
# import statistics
import bisect
import copy
import fractions
import math
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)

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

Submission status: Accepted

Solution code:
def main():
	R, G, B, N = map(int, input().split())
	r_max, g_max = N//R, N//G
	def search(ball, goal):
		if goal % ball == 0:
			return 1
		return 0
	ans = search(R, N)
	ans += search(G, N)
	ans += search(B, N)
	for r in range(1, r_max+1):
		if r*R >= N:
			break
		ans += search(G, N-r*R)
		ans += search(B, N-r*R)
		for g in range(1, g_max+1):
			if r*R+g*G >= N:
				break
			ans += search(B, N-r*R-g*G)

	for g in range(1, g_max+1):
		if g*G >= N:
			break
		ans += search(B, N-g*G)
	print(ans)


if __name__ == '__main__':
	main()

Submission status: Accepted

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

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

cnt = 0
for p0 in range(N//C[0]+1):
    p0v = p0*C[0]
    for p1 in range((N-p0v)//C[1]+1):
        p1v = p1*C[1]
        if (N - p0v - p1v)%C[2] == 0:
            cnt += 1
print(cnt)

Submission status: Accepted

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):
    x=n-(i*r+j*g)
    if x<0:
      break
    elif x%b==0:
      c+=1
print(c)

Submission status: Accepted

Solution code:


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

ans = 0

for ri in range(0,n//r+1):

    t = n - ri*r
    if t<0:
        break
    
    for gi in range(0,t//g+1):
        tt = t -gi*g
#        print((ri,gi,tt))
        if tt<0:
            break
        if tt%b == 0:
            ans += 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(i)

Submission status: Accepted

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

rmax = N // R

count = 0
for r in range(rmax+1):
    rem = N - r * R
    gmax = rem // G
    for g in range(gmax+1):
        remm = rem - g * G
        if remm % B == 0:
            count += 1

print(count)

Submission status: Accepted

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):
    N2 = n-i*l[2] // l[1]
    for j in range(N2+1):
        if ((n-i*l[2]-j*l[1]) % l[0] == 0) and ((n-i*l[2]-j*l[1]) // l[0] >= 0):
            cnt += 1
            # print(i, j, (n-i*l[2]-j*l[1]) // l[0])
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

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

cnt = 0
num = N
for i in range(0,N+1,R):
    tmp = num - i
    for j in range(0,N+1,G):
        tmp2 = tmp - j
        if tmp2%B == 0 and tmp2 >= 0:
            cnt += 1

print(cnt)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
R, G, B, N = map(int, input().split())
ls = [R, G, B]
ls.sort()
ans = 0
m = ls[-1]
r, g, b = 0, 0, 0
for i in range(N//m+1):
    for j in range((N-m*i)//ls[1] + 1):
        if (N - m*i - ls[1]*j)%ls[0] == 0:
            ans += 1
print(ans)

Submission status: Accepted

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

    count = 0
    for rr in range(n//r + 1):
        for gg in range((n-rr*r)//g + 1):
            if (n-rr*r-gg*g) % b == 0:
                count += 1
    print(count)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re

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):
		# print(r, g, b)
		# if R*i + G*j + B*int(max(0, (N - i*R - j*G))/B) == N:
		# 	count += 1
		if (N - i*R - j*G) % B == 0:
			count += 1
print(count)

Submission status: Accepted

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):
    x = n - i * c[0]
    for j in range(x // c[1] + 1):
        y = x - j * c[1]
        if y < 0:
            break
        elif y % c[2] == 0:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
r,g,b,n=list(map(int,input().split()))
ans=0
for gi in range(1,n+2):
  if (gi-1)%r!=0:
    continue
  else:
    for bi in range(gi,n+2):
      if (bi-gi)%g ==0 and (n-bi+1)%b==0 :
        ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
R,G,B,N = map(int, input().split())
values = [R,G,B]
values.sort(reverse = True)
a,b,c = values
ans = 0
for i in range(N//a+1):
    p = N - a*i
    for j in range(p//b + 1):
        q = p - b*j
        if q%c == 0:
            ans += 1
print(ans)

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N + 1):
  if i % R == 0:
    dp[i][0] = 1

for i in range(N + 1):
  if dp[i][0] != 0:
    for j in range(i,N + 1,G):
      dp[j][1] += dp[i][0]
for i in range(N + 1):
  if dp[i][1] != 0:
    for j in range(i,N + 1,B):
      dp[j][2] += dp[i][1]
print(dp[-1][2])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
R, G, B, N = list(map(int, input().split()))
 
count = len([1 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)])
print(count)

Submission status: Accepted

Solution code:
###############################################################################

from sys import stdout
import sys
from bisect import bisect_left as binl
from copy import copy, deepcopy


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


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

cache = {}


def calc_pattern2(x, a, b):
    global cache

    if (x, a, b) in cache:
        return cache[(x, a, b)]
    if x < 0:
        return 0
    if x == 0:
        return 1

    ans = 0

    ans += calc_pattern2(x - a - b, a, b)

    if x % a == 0:
        ans += 1
    if x % b == 0:
        ans += 1

    cache[(x, a, b)] = ans
    return ans


def calc_pattern3(x, a, b, c):
    global cache

    if (x, a, b, c) in cache:
        return cache[(x, a, b, c)]
    if x < 0:
        return 0
    if x == 0:
        return 1

    ans = 0

    ans += calc_pattern3(x - a - b - c, a, b, c)

    ans += calc_pattern2(x - a - b, a, b)
    ans += calc_pattern2(x - b - c, b, c)
    ans += calc_pattern2(x - c - a, c, a)

    if x % a == 0:
        ans += 1
    if x % b == 0:
        ans += 1
    if x % c == 0:
        ans += 1

    cache[(x, a, b, c)] = ans
    return ans


def main():
    sys.setrecursionlimit(5000)
    r, g, b, n = intin()
    print(calc_pattern3(n, r, g, b))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
R,G,B,N = (int(i) for i in input().split())
P = N//R
ans = 0
count1=0
count2=0
for i in range(P+1):
    left = N - i*R
    Q = left//G
    for j in range(Q+1):
        left1 = left - j*G
        if left1%B == 0:
            ans +=1
print(ans)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)


def main():
    a,b,c,n = LI()
    r = 0
    for i in range(0,n+1,a):
        t = n - i
        for j in range(0,t+1,b):
            k = t - j
            if k % c == 0:
                r += 1

    return r


print(main())

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
R, G, B, N = map(int, input().split())
list_a = [R, G, B]
list_a.sort()
ans = 0
for i in range(N//list_a[2]+1):
  nn = N-i*list_a[2]
  for j in range(nn//list_a[1]+1):
    nnn = nn-j*list_a[1]
    if nnn%list_a[0] == 0:
      ans+=1
print(ans)

Submission status: Accepted

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


print(ans)

Submission status: Accepted

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

N_b = N//rgb[2]
for i in range(N_b,-1,-1):
    x = N - i*rgb[2]
#    print(x)
    N_g = x//rgb[1]
    for j in range(N_g,-1,-1):
#        print(i,j)
        if (x - j*rgb[1])%rgb[0]==0:
            cnt += 1
print(cnt)

Submission status: Accepted

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

count = 0
r_max = int(N / R)+1
g_max = int(N / G)+1

for r in xrange(r_max):
    rest_val = N - R*r
    for g in xrange(g_max):
        rest_val2 = rest_val - G * g
        if rest_val2 < 0: break
        if rest_val2 % B == 0:
            # print "r="+str(r)+",g="+str(g)+",b="+str(rest_val2/B)
            count += 1

print count

Submission status: Accepted

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

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

Submission status: Accepted

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


ret = 0
for i in range(n//r+1):
    for j in range(n//g+1):
#         print((r*i+g*i), n, (n-(r*i+g*i))%b)
        tmp = r*i+g*j
        if tmp > n:
            continue
        if (n-tmp)%b == 0:
#             print(i, j, (n-(r*i+g*j))/b)
            ret += 1
print(ret)

Submission status: Accepted

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
            if (N-r-g) % B == 0:
                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: Accepted

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

print(count)

Submission status: Accepted

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

counter = 0
for r in range(3001):
    for g in range(3001):
        bB = N - r * R - g * G
        if bB < 0:
            break
        if bB % B == 0:
            counter += 1
print(counter)

Submission status: Accepted

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

r = N //R


for i in range(r+1):
    M = N - R * i
    g = M // G
    for j in range(g+1):
        O = M - G * j
        if O % B == 0:
            count += 1

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
R,G,B,N = map(int,input().split(' '))
count = 0
rr = int(N/R) +1
gg = int(N/G) +1
bb = int(N/B) +1
for r in range(rr):
    for g in range(gg):
        b = N - r*R - g*G
        if b<0:
            break
        if b%B==0:
            count+=1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0

for i in range(3001):
    if i*r > n:
        break
    for j in range(3001):
        value = r*i + g*j
        if (n - value) < 0:
            break
        elif (n - value) % b == 0:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
R,G,B,N=list(map(int, input().split()))
arr = [R,G,B]
arr = sorted(arr, reverse=True)
R,G,B = arr

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

Submission status: Accepted

Solution code:
import math
r, g, b, n = map(int, input().split())
ans = 0
for r_num in range(math.floor(n/r)+1):
    for g_num in range(math.floor(math.floor(n - r*r_num)/g)+1):
        if ((n - (r_num * r) - (g_num * g)) % b == 0):
            ans += 1
print(ans)

Submission status: Accepted

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):
    m=m-r*i
    for j in range((m//g)+1):
        c=m-j*g
        if c%y==0 and c>=0 :
            count+=1

    m=n

print(count)

Submission status: Accepted

Solution code:
R,G,B,n=map(int,input().split())
def cou(R,G,B,n):
    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
    return c
print(cou(R,G,B,n))

Submission status: Accepted

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

rcount=0
gcount=0
b=0
ans = 0

while rcount <= N:
    gcount = 0
    while rcount+gcount <= N:
        if (N - (rcount + gcount) ) % B == 0 :
            ans += 1
        gcount += G
    rcount += R

print(ans)

Submission status: Accepted

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

import math

counter = 0
for x in range(math.ceil(n / r) + 1):
    left = n - x * r

    for y in range(math.ceil(left / g) + 1):
        left2 = left - y * g

        if left2 >= 0 and left2 % b == 0:
            counter += 1
        # print(x, y, left2 / b)
print(counter)

Submission status: Accepted

Solution code:
def main(R, G, B, N):
    R, G, B = sorted((R, G, B))
    n = 0
    for b in range(N // B + 1):
        xb = N - b * B
        for g in range(xb // G + 1):
            xg = xb - g * G
            if xg % R == 0:
                n += 1   
    return n

print(main(*map(int, input().split())))

Submission status: Accepted

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

Submission status: Accepted

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

import numpy as np

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

count = 0
R_limit = N // R

for i in range(R_limit,-1,-1):
    N_temp = N - i*R
    G_limit = N_temp // G
    for j in range(G_limit,-1,-1):
        N_temp2 = N_temp - j * G
        B_mod = N_temp2 % B
        if B_mod == 0:
            count = count+1

print(count)

Submission status: Accepted

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 n % A[2] == 0
       
    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: Accepted

Solution code:
*lst,N = map(int, input().split())

lst.sort(reverse=True)
#print(lst)
count = 0
for i in range(N // lst[0] + 1):
    for j in range((N - i * lst[0]) // lst[1] + 1):
        if (N - i * lst[0] - j * lst[1]) % lst[2] == 0:
            count += 1
print(count)

Submission status: Accepted

Solution code:
def getlist():
	return list(map(int, input().split()))

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

print(ans)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

print(num)

Submission status: Accepted

Solution code:
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect, math
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

R,G,B,N = read_int()

def solve():
    ans = 0

    for i in range(0, N + 1, R):
        res = i
        if res > N: continue
        for j in range(0, N + 1 - res, G):
            res = i + j
            if res <= N and (N - res) % B == 0:
                ans += 1
    return ans

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

Submission status: Accepted

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

n=0
for r in range(N//R+1):
    N2 = N-R*r
    if N2==0:
        n+=1
        continue
    
    for g in range(N2//G+1):
        if (N2-G*g)%B==0:
            n+=1

print(n)

Submission status: Accepted

Solution code:
r, g, b, n = map(int, input().split())
cnt = 0
nr = 0
while nr * r <= n:
    m = n - nr * r
    ng = 0
    while ng * g <= m:
        l = m - ng * g
        if not l % b:
            cnt += 1
        ng += 1
    nr += 1
print(cnt)