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())
L = [r, g, b]
L.sort(reverse=True)
r, g, b = L[0], L[1], L[2]
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())
l=[r,g,b]
m=max(l)
l.remove(m)
m2=max(l)
l.remove(m2)
m3=l[0]
cnt = 0
for i in range(n//m + 1):
    n_ = n - m*i
    for j in range(n_//m2 + 1):
        if (n_ - m2*j)%m3==0:
            cnt += 1
print(cnt)

Submission status: Accepted

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

count = 0
for i in range(n+1):
    rr = i * r
    for j in range(n+1):
        gg = g * j
        bb = (n - rr - gg)
        if bb >= 0 and bb % b == 0:
            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):
        if i * r + j * g == n:
            cnt += 1
        elif (n - (i * r + j * g)) >= 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())
rm=n//r
count=0
for i in range(rm+1):
    rn=n-r*i
    gm=rn//g
    for j in range(gm+1):
        rn1=rn-g*j
        if rn1%b==0:
            count=count+1
print(count)

Submission status: Accepted

Solution code:


R, G, B, N = map(int, input().split())
rgb = []
for i in range(N + 1):
    for j in range(N - (i * R) + 1):
        key = i * R + j * G
        key = N - key
        if key % B == 0 and key / B >= 0:
            rgb.append([i, j, key // B])

#print(rgb)
print(len(rgb))

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
from collections import deque

INF = float('inf')
MOD = 10 ** 9 + 7
dy, dx = (0, -1, 0, 1), (1, 0, -1, 0)

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    r, g, b, n = LI()

    res = 0
    for ri in range(n // r + 1):
        for gi in range(n // g + 1):
            t = n - r * ri - g * gi
            if t >= 0 and t % b == 0:
                res += 1

    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

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

a = np.zeros(U+1,dtype = np.int64)

for r in range(0,U+1):
  x = R*r
  if x > U:
    break
  a[x::G] += 1


ans = a[N::-B].sum()
print(ans)

Submission status: Accepted

Solution code:
R,G,B,N = map(int, raw_input().split())
count = 0
while True:
	N2 = N
	while True:
		if(N2 % B == 0):
			count += 1
		N2 -= G
		if(N2 < 0):
			break
	N -= R
	if(N < 0):
		break
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
R, G, B, N = map(int, input().split())
ans = 0
for r in range(0, 3001, R):
    for g in range(0, 3001, G):
        b = N-r-g
        if b >= 0 and b % 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 + 1):
    for g in range(N + 1):
        X = N - (R * r) - (G *g)
        if X < 0:
            continue
        if X % B == 0:
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
a, b, c, n = map(int, input().split(" "))
if a > b:
    a, b = b, a
if b > c:
    b, c = c, b
if a > b:
    a, b = b, a

ans = 0
for numc in range(n//c + 1):
    left = n - c * numc
    for numb in range(left//b + 1):
        if (left - b*numb) % a == 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):
    for j in range((N-R*i)//G+1):
#         print(N-R*i-G*j)
        if (N-R*i-G*j) % B == 0:
#             print(i,j)

            cnt += 1
    
print(cnt)

Submission status: Accepted

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


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


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(R, G, B, N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# from sys import exit
R, G, B, N = [int(n) for n in input().split()]
# a = [int(input()) for _ in range(N)]
# S = str(input())
# L = len(S)
# T = str(input())
# exit()
ans = 0
for i in range(3001):
    for j in range(3001):
        le = N - i*R - j*G
        if (le) % B == 0 and le >= 0:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:


def main():
    r, g, b, n = map(int, raw_input().split())
    s = 0
    for i in range(n // r + 1):
        c = i * r
        if c == n:
            s += 1
            continue
        for j in range((n - c) // g + 1):
            cc = c + j * g
            if cc <= n and (n - cc) % b == 0:
                s += 1
    print s


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

maxR = int(n/r)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
range = xrange
input = raw_input

r,g,b,n = [int(x) for x in input().split()]

count = 0

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

print count

Submission status: Accepted

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

s = n//r
t = n//g

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

Solution code:
r,g,b,n=map(int, input().split())
r,g,b=sorted([r,g,b],reverse=True)
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=list(map(int,raw_input().strip().split(' ')))
R,G,B=sorted([R,G,B])[::-1]
dic={}
count=0
for i in xrange(0,N//(R)+1):
    temp=i*R
    for j in xrange(0,(N-temp)//G+1):
        temp2=j*G
        if (temp+temp2)<N+1 and (N-temp-temp2)%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>=0:
            if (n-r*x-g*y)%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(1-(-N//R)):
    for g in range(1-(-N//G)):
        K = N - R * r - G * g
        if not K % B and 0 <= K//B:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
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):
    if (_N - g * G) % B == 0:
      cnt += 1
print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

R,G,B,N=rl()
ans = [0]*(N+1)
ans[0] = 1
for color in [R,G,B]:
    for i in range(N+1):
        temp = i + color
        if temp <= N:
            ans[temp] += ans[i]
print(ans[N])

Submission status: Accepted

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


def solve(R: int, G: int, B: int, N: int):
    count = 0
    for x in range(N+1):
        for y in range(N+1):
            rest = N - R * x - G * y
            z, q = divmod(rest, B)
            if z < 0:
                break
            if q == 0:
                count += 1
    print(count)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(R, G, B, N)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
R,G,B,N = map(int,input().split())
ans = 0
for r in range(((N+R-1)//R)+1):
    for g in range(((N+G-1)//G)+1):
        if r*R+g*G>N:
            continue
        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())
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)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    r,g,b,n = f()
    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)

solve()

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

ans = 0
a = N // R
for r in range(a + 1):
    m = N - r * R
    b = m // G
    for g in range(b + 1):
        k = m - g * G
        if k % 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:
# coding: utf-8
# Your code here!

import sys
from collections import deque, Counter
import bisect
import math
from itertools import accumulate, product, permutations, combinations, groupby
from fractions import gcd 
import heapq
sys.setrecursionlimit(10**6)
#input = sys.stdin.readline #文字列入力のときは注意

R,G,B,n = [int(i) for i in input().split()]

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

print(ans)
    
     



#if ok == 1:
#   print("Yes")
#else:
#   print("No")

Submission status: Accepted

Solution code:
def main():
    from sys import stdin, stdout

    def read():
        return stdin.readline().rstrip('\n')

    def read_array(sep=None, maxsplit=-1):
        return read().split(sep, maxsplit)

    def read_int():
        return int(read())

    def read_int_array(sep=None, maxsplit=-1):
        return [int(a) for a in read_array(sep, maxsplit)]

    def write(*args, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in args) + end)

    def write_array(array, **kwargs):
        sep = kwargs.get('sep', ' ')
        end = kwargs.get('end', '\n')
        stdout.write(sep.join(str(a) for a in array) + end)

    r, g, b, n = read_int_array()
    dp = [0]*(n+1)
    dp[0] = 1
    for c in [r, g, b]:
        for i in range(c, n+1):
            dp[i] += dp[i-c]
    write(dp[-1])

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
R, G, B, n = list(map(int, input().split()))
ans = 0
mr = n // R
for i in range(mr + 1):
    m = n - i * R
    mg = m // G
    for j in range(mg + 1):
        l = m - j * G
        if l % 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+1):
    for j in range(n+1):
        nokori = n - r*i -g*j
        if nokori >= 0 and nokori % b == 0:
             cnt += 1
  
print(cnt)

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-i*r)//g+1):
        left = n - i*r - j*g
        if left >= 0 and left % 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//R)+1):

    k = n-R*i
    for s in range((k//G)+1):
        m = k - s*G
        if m%B == 0:
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
R,G,B,N = map(int,input().split())
ans = 0
for a in range(0,N+1,R):
    for b in range(0,N+1,G):
        if a+b > N: break
        c = N - a - b
        if c%B==0:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
R,G,B,N=[int(i) for i in input().split()]
rr=N//R
res=0
for i in range(rr+1):
	gb=N-R*i
	gg=gb//G
	for j in range(gg+1):
		if (gb-j*G)%B==0:
			res+=1
print(res)

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)//b+1):
    k = n-i*r-j*b
    if k%g == 0 and k>=0:
      cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
a, b, c, d = map(int ,input().split())

m = max(d/a, d/b, d/c)
m = int(m+1)
ans = 0
for i in range(m):
    for j in range(m):
        if((d - (i * a + j * b)) % c == 0 and i*a+j*b<=d):
            ans+=1
print(ans)

Submission status: Accepted

Solution code:
R,G,B,N=[int(x) for x in 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:
#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def main():
    r, g, b, n = map(int, input().split())
    res = 0
    for i in range(n + 1):
        for j in range(n + 1):
            x = n - r * i - g * j 
            if x >= 0 and x % b == 0:
                res += 1
    print(res)


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._buffer = BytesIO()
        self._fd = file.fileno()
        self._writable = "x" in file.mode or "r" not in file.mode
        self.write = self._buffer.write if self._writable else None

    def read(self):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

    def flush(self):
        if self._writable:
            os.write(self._fd, self._buffer.getvalue())
            self._buffer.truncate(0), self._buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
r,g,b,n = (int(num) for num in 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 r in range(N + 1):
    for g in range(N + 1):
        res = N - r * R - g * G
        if res >= 0 and res % 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):
        if N < r*R+g*G:
            continue
        if (N-(r*R+g*G)) % B == 0:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]


R, G, B, N = map(int, input().split())
ans = 0
for i in range(3001):
    for j in range(3001):
        tmp = N - i*R - G*j
        if tmp >= 0 and tmp % 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):
    if r>N//R:
        break
    for g in range(3001):
        if g>N//G:
            break

        rest=N-(r*R+g*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
for r in range(0, 3001):
    r_ = r*R
    for g in range(0, 3001):
        b = N - r_ - g*G
        if b < 0:
            continue
        if b%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 // R + 1):
    for g in range((N - r * R) // G + 1):
        if (N - r * R - g * G) % B == 0:
            res += 1

print(res)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

r,g,b,n = li()
ans = 0
for ri in range(0, n+1, r):
    for gi in range(0, n+1, g):
        if ri+gi > n:
            continue
        elif (n-ri-gi) % b:
            continue

        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:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
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 II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    R, G, B, N = LI()
    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
    return ans

print(main())

Submission status: Runtime Error

Solution code:
#include <stdio.h>

int main(){
  int R, G, B, N, ans = 0;
  scanf("%d %d %d %d", &R, &G, &B, &N);
  for(int i = 0; i <= 3000; i++){
    for(int j = 0; j <= 3000; j++){
      int v = R * i + G * j;
      if(N >= v && (N - v) % B == 0) ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Submission status: Runtime Error

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

ans = [0]*(N//R + 1)*(N//G + 1)*(N//B + 1)
for r in range(N//R + 1):
    for g in range(N//G + 1):
        for b in range(N//B + 1):
            k = r*R + g*G + b*B
            ans[k] += 1
print(ans)
print(ans[N])

Submission status: Runtime Error

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

ans = [0]*(N//R + 1)*(N//G + 1)*(N//B + 1)
for r in range(N//R + 1):
    for g in range(N//G + 1):
        for b in range(N//B + 1):
            n = r*R + g*G + b*B
            ans[n] += 1
print(ans[n])

Submission status: Runtime Error

Solution code:
cnt = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        if  (N - r*R - g*G) < 0:
            break
        if  (N - r*R - g*G)%B == 0 :
            cnt +=1
            #print(r,g,(N - r*R - g*G)//B)
print(cnt)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

Solution code:
[A,B,C,N]=[int(i) for i in input().split()]
[C,B,A]=[A,B,C].sort()
cnt=0
for i in range(N//A):
  k=N-(i*A)
  for j in range(k//B):
    if (k-(B*A))%C==0:cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
[A,B,C,N]=[int(i) for i in input().split()]
[C,B,A]=[A,B,C].sort()
cnt=0
for i in range(N//A):
  k=N-(i*A)
  for j in range(k//B):
    if (k-(B*A))%C=0:cnt+=1
print(cnt)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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