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 = map(int, input().split())

cnt = 0
for r in range(N//R+1):
    Rr = R*r
    for g in range((N-Rr)//G+1):
        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())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

def useOne(a, b, c, n):
    count = 0
    if n%a == 0: count += 1
    if n%b == 0: count += 1
    if n%c == 0: count += 1
    return count

def useTwo(a, b, n):
    a, b = sorted([a, b])
    count = 0
    maxCountOfA = n//a
    maxCountOfB = n//b
    
    startCount = 1
    for i in range(maxCountOfA, 0, -1):
        for j in range(startCount, maxCountOfB+1):
            _sum = i*a + j*b
            if _sum == n:
                count += 1
                startCount = j+1
                break
            if _sum > n:
                startCount = j
                break
    return count

def useThree(a, b, c, n):
    a, b, c = sorted([a, b, c])
    maxCountOfA = n//a
    maxCountOfB = n//b
    maxCountOfC = n//c
    count = 0
    for i in range(1, maxCountOfA+1):
        startCountOfC = maxCountOfC
        for j in range(1, maxCountOfB+1):
            _sum = i*a + j*b
            if _sum >= n:
                maxCountOfB = j
                break
            for k in range(startCountOfC, 0, -1):
                _sum = i*a + j*b + k*c
                if _sum == n:
                    count += 1
                    startCountOfC = k-1
                    break
                if _sum < n:
                    startCountOfC = k
                    break
    return count

def answer(a, b, c, n):
    count = useOne(a, b, c, n)
    count += useTwo(a, b, n)
    count += useTwo(a, c, n)
    count += useTwo(b, c, n)
    count += useThree(a, b, c, n)
    return count
    
a, b, c, n = map(int, input().split())
print(answer(a, b, c, n))

Submission status: Accepted

Solution code:
def solve():
    R, G, B, N = map(int, input().split())
    LIM = 3001
    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
    return ans


print(solve())

Submission status: Accepted

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

lst = [R, G, B]
lst.sort()
k2, k1, k0 = lst

ans = 0
if lst != [1, 1, 1]:
    for n0 in range(N//k0 + 1):
        for n1 in range(N//k1 + 1):
            nn = (N - n0 * k0 - n1 * k1)
            if nn >= 0 and nn % k2 == 0: ans += 1
    print(ans)
else:
    for n0 in range(N+1):
        for n1 in range(n0, N+1):
            if n0 + n1 > N:continue
            if n0 == n1: ans += 1
            else: ans += 2
    print(ans)

Submission status: Accepted

Solution code:
# dp array
import sys
input = sys.stdin.readline
def main():
    R, G, B, N = map(int, input().split())
    r_count = N // R
    g_count = N // G
    ans = 0
    for i in range(r_count+1):
        for j in range(g_count+1):
            k = N - R * i - G * j
            if k % B == 0 and k >= 0:
                ans += 1
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    A,B,C,N = map(int,input().split())
    ans = 0
    for i in range(N + 1):
        if i*A > N:
            break
        a = i*A
        for j in range(N + 1):
            if j*B + a > N:
                break
            b = j*B
            if (N - a - b)%C == 0:
                ans += 1
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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 :
            #print(r,g,(N-r-g))
            cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import fractions
import sys
from functools import reduce
import math

input = sys.stdin.readline


def main():
    r, g, b, n = input_list()
    ans = 0
    for x in range(n+1):
        for y in range(n+1):
            z = n - (x*r) - (y*g)
            if z < 0:
                continue
            if z % b != 0:
                continue
            ans += 1
    print(ans)


def get_camulative(l):
    import itertools
    # 累積和
    return [0] + list(itertools.accumulate(l))

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


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


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


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N=len(v)
    size=len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def main():
    mod = 10**9+7
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    R,G,B,N = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    l1=[0]*(N+1)
    for r in range(N//R+1):
        for g in range(N//G+1):
            count=R*r+g*G
            if count>N:
                break
            l1[count]+=1
    ans=0
    #print(l1)
    for b in range(N//B+1):
        ret=N-b*B
        ans+=l1[ret]
    print(ans)



if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
r,g,b,n=map(int,input().split())
p=0
i,j=0,0
while j < n+1:
    k=i*r+j*g
    if (n-k)%b==0 and k <= n:
        #print(i,j,n-k)
        p+=1
    i+=1
    if i>n:
        i=0
        j+=1
print(p)

Submission status: Accepted

Solution code:
R, G, B, N = map(int, input().split())
# print("(N,R,G,B)=({},{},{},{})".format(N,R,G,B))

ans = 0
for i in range(N+1):
    if R*i > N:
        break
    for j in range(N+1):
        tmp = R*i + G*j
        # print("i={},j={},tmp={}".format(i,j,tmp))
        if tmp > N:
            break
        if (N-tmp)%B == 0:
            ans += 1
            # print("(i,j,k)=({},{},{})".format(i,j,(N-tmp)//B))
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import deque


def read():
    R, G, B, N = map(int, input().strip().split())
    return R, G, B, N


def solve(R, G, B, N):
    count = 0
    for r in range(N+1):
        for g in range(N+1):
            x = N - R * r - G * g
            if x >= 0 and x % B == 0:
                count += 1
    return count


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    R,G,B,N=map(int, input().split())
    cnt=0
    rnum=N//R
    gnum=N//G
    for r in range(rnum+1):
        for g in range(gnum+1):
            x=R*r+G*g
            if x>N:
                break
            else:
                if (N-x)%B==0:
                    cnt+=1
    print(cnt)
resolve()

Submission status: Accepted

Solution code:
def pat(R,G,B,N):
    output = 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:
                output += 1
    return output

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

    ans = pat(R,G,B,N)

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
R, G, B, N = map(int, input().split())
MAX_R = N // R + 1
MAX_G = N // G + 1
ans = 0
for i in range(MAX_R):
    for j in range(MAX_G):
        b_cnt = N - R * i - G * j
        if b_cnt >= 0 and b_cnt % 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-r*i)//g)+1):
        if (n-r*i-g*j) % 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):
        k = n - (i * r + j * g)
        if k % b == 0:
            ans += 1

print(ans)

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

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

BALL = [0]*(N+100)
BALL[0] = 1

for num in range(0,N+1,1):
    if BALL[num] != 0 and num + R <= N:
        BALL[num+R] += BALL[num]
for num in range(0,N+1,1):
    if BALL[num] != 0 and num + G <= N:
        BALL[num+G] += BALL[num]

for num in range(0,N+1,1):
    if BALL[num] != 0 and num + B <= N:
        BALL[num+B] += BALL[num]

print(BALL[N])

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

R, G, B, N = nm()


def solve():
    ans = 0
    for r in range(N // R + 2):
        for g in range(N // G + 2):
            k = N - (r * R + g * G)
            if k < 0:
                break
            if k % B == 0:
                ans += 1
    return ans


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def main():
    R, G, B, N = map(int, input().split())
    ans = 0
    #anslist = []
    for r in range(3005):
        rtmp = R*r
        if rtmp > N:
            break
        for g in range(3005):
            gtmp = G*g
            if gtmp > N:
                break
            btmp = N - (rtmp + gtmp)
            if btmp < 0:
                continue
            ans += btmp%B==0
            #if btmp%B==0:
            #    b = btmp//B
            #    anslist.append((r,g,b))
    
    #print(anslist)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
R, G, B, N = map(int, input().split())
R, G, B = sorted([R, G, B], reverse=True)
maxR = N // R
ans = 0
if R == 1:
    ans = (N+2)*(N+1) // 2
    print(ans)
    quit()

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

Solution code:
def main():
    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)
main()

Submission status: Accepted

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

Solution code:
r, g, b, n = map(int, input().split())
ball = [0, r, g, b]
dp = [[0] * 4 for _ in range(n+1)]
dp[0][0] = 1

for i in range(n+1):
    for k in range(4):
        if k == 0:
            if i != 0:
                dp[i][k] = 0
        else:
            if i - ball[k] < 0:
                dp[i][k] = dp[i][k-1]
            else:
                dp[i][k] = dp[i-ball[k]][k] + dp[i][k-1]

print(dp[n][3])

Submission status: Accepted

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

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

ans = 0
for r in range(N//R+1):
    for g in range((N-r*R)//G+1):
        tmp = (N-r*R-g*G)/B
        if tmp.is_integer():
            ans += 1

print(ans)

Submission status: Accepted

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()))

#pythonだとTLE/pypyだとAC
'''
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)
'''

#上を受けてpythonでも通るように改良
*num,n = iim()
a,b,c = map(int,sorted(num))
ans = 0
for i in range(n//c+1):
    if a!= 1:
        for j in range(n//b+1):
            num = n-i*c-j*b
            if num%a == 0 and num//a >= 0:
                ans += 1
    else:
        ret = n - i*c
        ans += ret//b+1
print(ans)

Submission status: Accepted

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:
         ans+=1
print(ans)

Submission status: Accepted

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

ans = 0
for r in range(3010):
  red = r * R
  if N < red:
    break
  
  for g in range(3010):
    green = g * G
    blue = N - red - green
    if blue < 0:
      break
    if blue % B == 0:
      ans += 1
      
print(ans)

Submission status: Accepted

Solution code:
import sys

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


def solve():
    R, G, B, N = map(int, rl().split())
    
    ans = 0
    for r in range(0, N + 1, R):
        for g in range(0, N + 1, G):
            if N < r + g:
                break
            if (N - r - g) % B == 0:
                ans += 1
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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)]


def main():
    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)

main()

Submission status: Accepted

Solution code:
R, G, B, N = map(int, input().split())
"""
3000以下なので全探索を考える。
まず，全探索できるものは全探索から考える必要がある。
オーダーを計算し，いけそうならそれで行くべき。今回は固定を順にしていくので間に合う
そこから探索する範囲を絞り込んで
"""

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue May 12 14:18:43 2020

@author: shinba
"""

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

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

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

print(ans)

Submission status: Accepted

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


def main() -> None:
    """Entry point
    """
    # 求解処理
    """
    r, gをそれぞれ固定して探索を行う.
    """
    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
            # この時点でNよりも大きい場合、何もしない
            if N < n_rg:
                continue
            # Nまでの不足分がBで割り切れる場合、条件を満たしたことになる
            if (N - n_rg) % B == 0:
                result += 1

    # 結果出力
    print(result)


if __name__ == "__main__":
    main()

Submission status: Accepted

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


def main() -> None:
    # 求解処理
    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)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

def resolve():
    R,G,B,N=pin()
    cnt=0
    for r in range(N+1):
        for g in range(N+1):
            t=(R*r+G*g)
            if N<t:continue
            if (N-t)%B==0:
                #print(r,g,t)
                cnt+=1
    print(cnt)
#%%submit!    
resolve()

Submission status: Accepted

Solution code:
rgb = [0]*3
rgb[0],rgb[1],rgb[2],n = map(int,input().split())
rgb.sort()

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

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-i*a[2])//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: Accepted

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

Submission status: Accepted

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 < 0:
                break
            if tmp % b == 0:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

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:
R, G, B, n = map(int, input().split())

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

Submission status: Accepted

Solution code:
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[-1])

Submission status: Accepted

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:
            break
        if s%R == 0:
            ans += 1

print(ans)

Submission status: Accepted

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

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

ans = 0
cnt = 0
cnt2 = 0
for i in range(N+1):
    cnt = R * i
    for j in range(N+1):
        cnt2 = cnt + G * j
        if cnt2 == N:
            ans += 1
            continue
        if cnt2 > N:
            continue
        else:
            nokori = N - cnt2
            if nokori % 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(3001):
    for g in range(3001):
        tmp = (R*r+G*g)
        if tmp > N:
            break

        if (N-tmp) % B == 0 or tmp == N:
            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-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())

count = 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:
            count += 1
            
print(count)

Submission status: Accepted

Solution code:
n=list(map(int,input().split()))
a= str(n[0])+str(n[1])+str(n[2])
maiden=0;z=0;iguales=4504501;iguales_2=1127251;iguales_3=2253001
if(n[0]==1 and n[1]==1 and n[2]==1):
    for k in range(3000-n[3]):
        iguales = iguales-(3001-k)
    print(iguales)
elif(n[0]==2 and n[1]==2 and n[2]==2):
    if(n[3]%2==0):
        for k in range(int((3000-n[3])/2)):
            iguales_2 = iguales_2-(1501-k)
        print(iguales_2)
    else:
        print(0)
elif(a=='121'or a=='112' or a=='211' and n[3]>=2997):
    for k in range(int(3000 -n[3])):
            iguales_3 = iguales_3-(1501-k)
    print(iguales_3)
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: Accepted

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

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

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):
        b=N-(R*i+G*j)
        if b==0 or  b%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())
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%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:
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    R, G, B, N = map(int, readline().split())
    ans = 0
    for r in range(3001):
        if R*r>N:
            break
        for g in range(3001):
            b = N - R*r - G*g
            if b<0:
                break
            if b%B==0:
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
SIZE = 3001
def main():
    output = 0
    R, G, B, N = (int(_) for _ in input().split())
    for r in range(SIZE):
      for g in range(SIZE):
        b = N - r * R - g * G
        if 0 <= b and b%B == 0: output += 1
    print(output)
    return

if __name__ == '__main__':
    main()

Submission status: Accepted

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_r//G)+1):
    balls_g = balls_r - G*g
    if (balls_g >= 0) and (balls_g % B == 0):
      ans += 1

print(ans)

Submission status: Accepted

Solution code:
def main():
    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)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

cnt = 0
for i in range(3001):
    for j in range(3001):
        if (n-i*r-j*g) % b == 0 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())

def it():
    for i in range(N//R+1):
        r = R*i
        for j in range((N-r)//G+1):
            g = G*j
            b = N - r - g
            if b % B == 0:
                yield 1

print(sum(it()))

Submission status: Accepted

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-i):
            _b = N - (i * R + j * G)
            
            if _b % B == 0 and _b >= 0:
                cnt += 1

    print(cnt)

if __name__ == "__main__":
    resolve()

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 - 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())
ans = 0
for r in range(3001):
    for g in range(3001):
        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:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    R, G, B, n = map(int, input().split())

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

    print(res)


if __name__ == '__main__':
    resolve()