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

Submission status: Accepted

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

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

        if N_3%B == 0:
            cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
R, G, B, N = list(map(int, input().split()))

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

print(answer)

Submission status: Accepted

Solution code:
from math import ceil


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

r,g,b,n = na()
ans=0
for i in range(n//r+1):
    a = n-r*i
    for j in range(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):
  for j in range(3001):
    buy = i*r + j*g
    if n - buy < 0:
      break
    elif (n - buy)%b == 0:
      ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def myAnswer(R:int,G:int,B:int,N:int) -> int:
   ans = 0
   for i in range(0,N+1,R):
      for j in range(0,N+1,G):
         k = N - j - i
         if( k % B != 0 or k < 0):
            continue
         else:
            # print(i,j,k)
            ans += 1

   return ans

def modelAnswer():
   return
def main():
   R,G,B,N = map(int,input().split())
   print(myAnswer(R,G,B,N))
if __name__ == '__main__':
   main()

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

Submission status: Accepted

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

dic = defaultdict(int)
for i in range(n // r + 1):
    for j in range(n // g + 1):
        dic[i * r + j * g] += 1


ans = 0
for k in range(n // b + 1):
    num = n - k * b
    ans += dic.get(num, 0)
print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
R,G,B,N = (int(x) for x in input().split())
maxr = N // R
maxg = N // G
count = 0
for i in range(maxr+1):
    for j in range(maxg+1):
        checker = N - (i*R + j*G)
        if checker // B >= 0:
            if checker % B == 0:
                count += 1
        elif checker == 0:
            count += 1
print(count)

Submission status: Accepted

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

cnt = 0
for i in range(n//a+1):
  an = n - a * i
  if an >= 0:
    for j in range(an//b+1):
      num = an - b * j
      if num >= 0 and num % c == 0:
        cnt+=1
        
print(cnt)

Submission status: Accepted

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

cnt = 0
for i in range(n//a+1):
  an = n - a * i
  for j in range(an//b+1):
    num = an - b * j
    if num >= 0 and num % c == 0:
      cnt+=1
        
print(cnt)

Submission status: Accepted

Solution code:
import math
R, G, B, N = map(int, input().split())
ans = 0
cr = math.ceil(N/R)
cg = math.ceil(N/G)
cb = math.ceil(N/B)
for i in range(cr + 1):
    for j in range(cg + 1):
        tmp =  i * R + j * G
        if N - tmp >= 0 and (N - tmp) % B == 0:
           ans += 1
        elif N - tmp < 0:
          break
print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    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)


if __name__=='__main__':
    main()

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
R, G, B, N = map(int, input().split())
R_max = N // R + 1
G_max = N // G + 1
B_max = N // B + 1
ans = 0
for i in range(0, R_max):
    for j in range(0, G_max):
        #for k in range(0, B_max):
            #if i * R + j * G + k * B == N:
        #a, b = divmod(N - (i * R + j * G), B)
        if (N - (i * R + j * G)) % B == 0 and (N - (i * R + j * G)) >= 0:
            #print('ans', i, j)
            ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

read = sys.stdin.buffer.read
# input = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a, b, c, n = map(int, input().split())
ans = 0
for i in range(3001):
    for j in range(3001):
        if n >= i * a + j * b and (n - i * a - j * b) % c == 0:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
r,g,b,n = map(int,input().split(' '))
A = [r,g,b]
A.sort()
r,g,b = A[2], A[1], A[0]
rmax, gmax = n//r, n//g
count = 0
i = 0
while i <= rmax:
    j = 0
    if g == 1:
        count += (n-i*r)+1
        j += 30000
    while (n-i*r-j*g) >= 0:
        if (n-i*r-j*g)%b == 0:
            count += 1
        j += 1
    i += 1
print(count)

Submission status: Accepted

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

# B - RGB Boxes
R, G, B, N = map(int, input().split())
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    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-(i*r + j*g)) % b == 0:
                ans += 1
    print(ans)
resolve()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
r_p = n // r
for i in range(n // r + 1):
    tmp = n - r * i
    for j in range(tmp // g + 1):
        remain = tmp - g * j
        if remain % 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):
        ball = N - r * R - g * G
        check = (ball / B)
        if check.is_integer() and check >= 0:
            ans += 1
print(ans)

Submission status: Accepted

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

a = max(R, G, B)
if a == R:
  b = max(G, B)
elif a == G:
  b = max(B, R)
else:
  b = max(R, G)
c = min(R, G, B)
for i in range(N//a+1):
  for j in range((N-a*i)//b+1):
    if ((N-a*i)-b*j)%c == 0:
      ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
R,G,B,N=map(int,input().split())
cnt=0
a=max(R,G,B)
if a==R:
  b=max(G,B)
elif a==G:
  b=max(B,R)
else:
  b=max(R,G)
c=min(R,G,B)
for i in range(N//a+1):
  for j in range((N-a*i)//b+1):
    if ((N-a*i)-b*j)%c==0:
      cnt+=1
print(cnt)

Submission status: Accepted

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

# 赤ボール
for r in range(N + 1):
    for g in range(N + 1 - r):
        b = N - r - g
        if r % R == 0 and g % G == 0 and b % B == 0:
            ctr += 1

print(ctr)

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
        if b < 0 or b%B: continue
        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//g+1):

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    R, G, B, N = (int(i) for i in input().split())
    ans = 0
    for r in range(N+1):
        for g in range(N+1):
            need = N - r*R - g*G  # 必要ボール数
            if need < 0:
                continue
            b = 0--need//B
            if r*R + g*G + b*B == N:
                ans += 1
                # print(r, g, b)
    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(0,N//R+1):
  for j in range(0,(N-i*R)//G+1):
    k = N - i*R -j*G
    if k%B == 0 and k>= 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):
        if n-i*r-j*g >= 0 and (n-i*r-j*g) % b == 0:
            cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    R, G, B, N = map(int, input().split())
    count = 0
    for i in range(N // R + 1):
        red = R * i
        lem = N - red
        for j in range(lem // G + 1):
            green = G * j
            if (lem - green) % B == 0: count += 1
    print(count)

    return 0

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

print(ans)

Submission status: Accepted

Solution code:
def solve():
    r,g,b,n = map(int,input().split())
    ans = 0
    for i in range(n+1):
        if r*i>n:
            break
        for j in range(n+1):
            if g*j+r*i>n:
                break
            if (n-g*j-r*i)%b==0:
                ans+=1
    print(ans)
if __name__=='__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

r, g, b, n = map(int, read().split())
cnt = 0
for i in range(n // r + 1):
    for j in range(n // g + 1):
        check = n - (r * i + g * j)
        if check >= 0:
            if check % b == 0:
                cnt += 1
        else:
            break
print(cnt)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

r, g, b, n = map(int, read().split())
cnt = 0
for i in range(n + 1):
    for j in range(n + 1):
        check = n - (r * i + g * j)
        if check >= 0:
            if check % b == 0:
                cnt += 1
        else:
            break
print(cnt)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
r0,g0,b0,n=map(int,input().split())
ans=0
l=[r0,g0,b0]
l.sort(reverse=True)
r=l[0]
g=l[1]
b=l[2]
x=0
while x*r<=n:
    y=0
    if g==1:
        ans+=1+n-x*r
        x+=1
        continue
    if b==1:
        ans+=1+(n-x*r)//g
        x+=1
        continue
    while y*g<=n-x*r:
        if (n-x*r-y*g) % b == 0:
            ans+=1
        y+=1
    x+=1
print(ans)

Submission status: Accepted

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

ans = 0

for x in range(n//r + 1):
    for y in range(n // g + 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())

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

print(ans)

Submission status: Accepted

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

max_r, max_g = math.floor(n/r),math.floor(n/g)

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

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())
count= 0
sum = 0

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

print(count)

Submission status: Accepted

Solution code:
a,b,c,n = map(int,input().split())
ans = 0
for i in range(0,3001):
  for j in range(0,3001):
    dum1,dum2 = divmod((n-(a*i+b*j)),c)
    if dum2 == 0 and dum1 >= 0:
      ans += 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

if __name__=="__main__":
    main()

Submission status: Accepted

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

res = 0
for i in range(N+1):
  count = R*i
  if N < count:
    break
  for j in range(N+1):
    count = R*i + G*j
    if N < count:
      break
    else:
      if (N - count) % B == 0:
        res += 1

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

print(cnt)

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

Submission status: Accepted

Solution code:
r,g,b,n=map(int,input().split())
def INT(m):
  if int(m)==m:
    return True
  return False
aa=[r,g,b]
aa.sort()
a,b,c=aa[0],aa[1],aa[2]
ans=0
for i in range(n//c +1):
  for j in range((n-i*c)//b +1):
    if INT((n-i*c-j*b)/a):
      ans+=1
print(ans)

Submission status: Accepted

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

cnt = 0
for ri in range(3000 // r + 1):
    left1 = n - ri * r
    for bi in range(left1 // b + 1):
        left2 = left1 - bi * b
        if left2 >= 0 and left2 % g == 0:
            cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

r,g,b,n=mii()
arr=sorted([r,g,b])

gg=n//arr[1] +1
bb=n//arr[2] +1
ans=0



for i in range(gg):
    for j in range(bb):
        if (n-(arr[1]*i+arr[2]*j))%arr[0]==0 and (n-(arr[1]*i+arr[2]*j))>=0:
            ans+=1


print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    R, G, B, n = LI()
    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 r * R + g * G + b * B == n:
                
                ans += 1
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

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

ans = 0
n_iter_r = N//R + 1
n_iter_g = N//G + 1

for r in range(n_iter_r):
    for g in range(n_iter_g):
        nokori = N - R*r - G*g
        if nokori < 0:
            break
        else:
            if nokori%B==0:
                ans += 1

print(ans)

Submission status: Accepted

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

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

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

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

print(ans)

Submission status: Accepted

Solution code:
def main():
    red_box, green_box, blue_box, target = map(int, input().split())
    answer = 0
    for i in range(target // red_box + 1):
        for j in range(target // green_box + 1):
            now_balls = red_box * i + green_box * j
            if (target - now_balls) % blue_box == 0 and target >= now_balls:
                answer += 1
            elif target < now_balls:
                break
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

RL=(N+R-1)//R
if RL*R>N:
    RL=RL-1

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

print(cnt)

Submission status: Accepted

Solution code:
def main():
    r, g, b, n = map(int, input().split())
    ans = 0
    x, y = 0, 0
    while r*x <= n:
        m = n - r*x
        y = 0
        while g*y <= m:
            if (m - g*y) % b == 0:
                ans += 1
            y += 1
        x += 1
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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):
        t = (N-i*r-j*g)
        if t%b ==0 and t>=0:
            #print(i,j,t//b)
            c+=1
print(c)

Submission status: Accepted

Solution code:
# import bisect
# from collections import Counter, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    r, g, b, n = list(map(int,ipti().split()))
    ans = 0
    r_max = n // r

    for rn in range(r_max+1):
        rem = n - r * rn
        g_max = rem // g
        for gn in range(g_max+1):
            rem2 = rem - g * gn
            if rem2 % b == 0:
                ans += 1

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

while r*r1 <= n:
    g1 = 0
    while r*r1+g*g1 <= n:
        if (n-(r*r1+g*g1))%b==0:
            count += 1
        g1 += 1
    r1 += 1
print(count)

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    R, G, B, N = [int(x) for x in stdin.readline().rstrip().split()]
    count = 0
    for r in range(3001):
        if N < r * R:
            break
        for g in range(3001):
            if N < g * G:
                break
            tmp = N - (R * r + G * g)
            if tmp < 0:
                break
            if tmp % B == 0:
                count += 1
    print(count)


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

Submission status: Accepted

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

a = [R, G, B]
a.sort()

x = N // a[2]
ans = 0
for i in range(x+1):
    n = N - (i * a[2])
    y = n // a[1]
    for j in range(y+1):
        if (n - a[1] * j) % a[0] == 0:
            ans += 1
print(ans)

Submission status: Accepted

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

   

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

else:
    tmp = n // b
    ans =  0
    for i in range(tmp+1):
        ans += n - i + 1
    print(ans)