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:
import sys
input = sys.stdin.readline


def main():
    r, g, b, n = map(int, input().split())
    ans = 0
    for i in range(n//r + 1):
        for j in range(n//g + 1):
            residue = n - i*r - g*j
            if residue >= 0 and residue % 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 x in range(n // r + 1):
    for y in range((n - r * x) // g + 1):
        z = (n - r * x - g * y) / b
        if z.is_integer():
            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:
import sys

stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    r, g, b, n = nm()
    ans = 0
    for i in range(n + 1):
        if n - i * r < 0:
            break
        for j in range(n + 1):
            num = n - r * i - g * j
            if num < 0:
                break
            if (num > 0 and num % b == 0) or num == 0:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, math
from functools import lru_cache
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    R, G, B, N = mi()
    cnt = 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 and 0 <= bB:
                cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

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):
        rg = R * i + G * j

        if rg <= N:
            if (N - rg) % B == 0:
                ans += 1

        else:
            break

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import collections


def main():
    cnt = 0
    R, G, B, N = list(map(int, input().split()))
    for r in range(N // R + 1):
        for g in range((N - r * R)//G + 1):
            k = N - r * R - g * G
            if k % B == 0:
                cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
from math import ceil
from numba import njit

@njit(cache=True)
def solve(rm,gm,bm,R,G,B,n):
    ans = 0
    for r in range(rm+1):
        for g in range(gm+1):
            x = n-(r*R+g*G)
            if x >= 0:
                ans += (x%B == 0)
    return ans
R, G, B, n = map(int, input().split())
rm = ceil(n / R)
gm = ceil(n / G)
bm = ceil(n / B)

print(solve(rm,gm,bm,R,G,B,n))

Submission status: Accepted

Solution code:
r,g,b,n=map(int,input().split())
ans=0
for i in range(1+n//r):
    for j in range(1+(n-r*i)//g):
        if (n-i*r-g*j)%b==0 and (n-i*r-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 // g + 1):
        m = r * i + g * j
        if m <= n and (n - m) % b == 0:
            ans += 1
        elif m > n:
            break

print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
r,g,b,n = map(int, input().split())
ans = 0
rgb = sorted([r,g,b])
n_rgb = []
for e in rgb:
  n_rgb.append(n//e)
for i in range(n_rgb[2]+1):
  N2 = n-i*rgb[2]
  for j in range(n_rgb[1]+1):
    N = N2 - j*rgb[1]
    if  N>=0 and N%rgb[0]==0:
      ans+=1
      
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

cnt = 0
for i in range(n//r + 1):
    for j in range(n//g + 1):
        nb = (n - (i*r+j*g))

        if (nb >= 0):
            if (nb % b == 0):
                cnt += 1
        else:
            break

print(cnt)

Submission status: Accepted

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

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

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

print(dp[-1])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

count = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	B
# CreatedDate:  2020-07-29 14:22:57 +0900
# LastModified: 2020-07-29 14:45:16 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    R, G, B, N = map(int, input().split())
    r_max = N//R
    g_max = N//G
    b_max = N//B
    cnt = 0
    for r in range(r_max+1):
        ans = r*R
        for g in range((N-r*R)//G+1):
            ans += g*G
            if (N-ans)%B==0:
                cnt += 1
            ans = r*R
    print(cnt)





if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
R,G,B,N = [int(i) for i in input().split()]
c = 0
for i in range(0,N+1,R):
    for j in range(0,N+1,G):
        if (N - i - j) < 0:
            break
        if (N - i - j)%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-i*R)//G+1):
    b = (N-R*i-G*j)/B
    if b%1 == 0 and b >= 0:
      ans += 1
print(ans)

Submission status: Accepted

Solution code:
r,g,b,n = map(int,input().split())
p = 0
for i in range(n+1):
    ri = r*i
    if ri > n:
        break
    else:
        for j in range((n+1)-(r*i)):
            gj = g*j
            if ri + gj > n:
                break
            else:
                if (n - (ri + gj)) % b == 0:
                    p += 1
print(p)

Submission status: Accepted

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

for i in range(n+1):
    x = i*r
    if x > n:
        break
    for j in range(n+1):
        y = j*g
        z = n-x-y
        if x+y > n:
            break
        if z >= 0 and z%b == 0:
            ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2020/07/26
# diverta 2019 Programming Contest - B

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

ans = 0

# Calc
for ir in range(n+1):
    vr = r * ir 
    if vr > n:
        break

    for ig in range(n+1):
        vg = g * ig 
        if vg + vr > n:
            break
        cb = n - vr - vg
        if cb % b == 0:
            ans = ans + 1

# Output
print(ans)

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
R,G,B,n = readInts()
cnt = 0
for r in range(n+1):
    for g in range(n+1):
        b = n - r*R - g*G
        #print(r,g,b)
        if b >= 0:
            if b%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(0,N+1,R):
    for g in range(0,N+1,G):
        if r+g > N:break
        if (N-r-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//G+1):
        n = N-r*R-g*G
        if n>=0 and n%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(N+1):
    for g in range(N+1):
        temp = N - r*R - g*G
        if temp < 0:
            continue
        if temp%B == 0:
            ans += 1
print(ans)

Submission status: Accepted

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

ans=0
i=0
while i<=3000:
    j=0
    while j<=3000 and N-(i*R+j*G)>=0:
        if (N-(i*R+j*G))%B==0:
            ans+=1
        j+=1
    i+=1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    R, G, B, N = LI()

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

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
r, g, b, n = map(int, input().split())
c = 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:
            c += 1
print(c)

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

l = sorted([r, g, b])
x = l[0]
y = l[1]
z = l[2]

ans = 0

mz = n // z
for i in range(mz + 1):
    my = (n - z * i) // y
    for j in range(my + 1):
        if (n - z * i - y * j) % x == 0:
            ans += 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

def solve(r,b,g,n):
  r_max = n // r
  b_max = n // b
  g_max = n // g
  ans = 0
  for i in range(r_max+1):
    for j in range(b_max+1):
      rest = n - (r*i + b*j)
      if rest >= 0 and rest % g == 0:
        ans += 1
  return ans



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

if __name__ == '__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
r,g,b,n=map(int,input().split())
c=0
for i in range(3001):
  for j in range(3001):
    if (n-i*r-j*g)%b==0 and 0<=n-i*r-j*g:
      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//g+1):
        nn = n - r*i - g*j
        if nn < 0:
            break
        if nn % b == 0:
            ans += 1
print(ans)

Submission status: Accepted

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

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

res = 0
v = 0
for i in range(n//r+1):
    for j in range(n//g+1):
        v = n-(i*r+j*g)
        #print('r,g,b=',i,j,v)
        if 0 <= v and v % b == 0:
            res += 1
        if v<0:break
print(res)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    a,b,c,n = [int(x) for x in input().split()]
    cnt = 0
    for i in range(0,n+1,a):
        for j in range(0,n+1,b):
            if i + j == n or (
                i + j < n and (
                    (n - (i + j)) % c == 0
                )):
                cnt += 1
    print(cnt)


    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

1 + k



"""

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    a,b,c,n = [int(x) for x in input().split()]
    d = [0] * 10000
    d[0] = 1
    for i in range(0,5000):
        d[i + a] += d[i]
    for i in range(0,5000):
        d[i + b] += d[i]
    for i in range(0,5000):
        d[i + c] += d[i]

    print(d[n])
    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

1 + k



"""

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    R, G, B, N = il()
    rlimit = (N // R) + 1
    glimit = (N // G) + 1

    ret = 0
    for r in range(rlimit):
        for g in range(glimit):
            n = N - (R * r + G * g)
            if n > -1 and n % B == 0:
                ret += 1
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

i = 0
cnt = 0

while i*R <= N:
  j = 0
  while i*R + j*G <= N:
    if (N - i*R - j*G) % B == 0:
      cnt += 1
    j += 1
  i += 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):
        tmp = (r*i)+(g*j)
        if tmp > n:
            break
        else:
            if (n-tmp)%b == 0:
                ans += 1

print(ans)

Submission status: Accepted

Solution code:
# 26
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


R, G, B, N = LI()
ans = 0
for r in range(N + 1):
    for g in range(N + 1):
        bB = N - r * R - g * G
        b = bB // B
        if bB >= 0 and bB % B == 0 and R * r + G * g + B * b == N:
            # print(f'{(r, g, b)=}')
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy

## input

# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))

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

ans = 0
tmp1 = N//R + 1

for i in range(tmp1):
    tmp2 = (N - R*i)//G + 1
    for j in range(tmp2):
        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
for i in range(0,n+1,r):
    for j in range(0,n+1,g):
        if i + j <= n:
            if (n - (i + j)) % b == 0: 
                    count += 1
print(count)

Submission status: Accepted

Solution code:
# from pprint import pprint
# import math
# import collections

# n = int(input())
R, G, B, N = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

# max_r, max_g, max_b = N // R, N // G, N // B
ans = []

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

max_r = N // R
for r in range(max_r + 1):
    if R * r > N:
        break

    max_g = (N - R * r) // G

    for g in range(max_g + 1):
        if R * r + G * g > N:
            break
        x = (N - (R * r + G * g))
        if x % B == 0 and x >= 0:
            # b = x // B
            # a = (r, g, b)
            cnt += 1
            # ans.append(a)

# print(len(ans))
print(cnt)

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):
        b=(N-r*R-g*G)//B

        if b>=0 and r*R+g*G+b*B==N:
            ans+=1

print(ans)

Submission status: Accepted

Solution code:
def main():
    r,g,b,n = map(int,input().split())
    c = 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:
                c += 1
            
    print(c)

main()

Submission status: Accepted

Solution code:
R, G, B, N = map(int, input().split())
counter = 0
r_max = N//R+1
for r in range(r_max+1):
  temp = N - R*r
  for g in range(temp//G+1):
    now = temp - G*g
    if now% B == 0 and now//B >= 0:
      counter +=1
print(counter)

Submission status: Accepted

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

numbers=[R,G,B]
new_numbers=sorted(numbers,reverse=True)
a=new_numbers[0]
b=new_numbers[1]
c=new_numbers[2]

answer=0

for n in range(N//a+1):
    A=a*n
    B=N-A
    for n_ in range(B//b+1):
        C=n_*b
        D=B-C
        if D%c==0:
            answer+=1
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    R,G,B,N=MI()
    ans=0
    for r in range(0,N+1,R):
        for g in range(0,N+1-r,G):
            b=N-r-g
            if b%B==0:
                ans+=1
                
    print(ans)

main()

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

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 and (n-i*r-j*g)>=0:
      ans+=1
print(ans)

Submission status: Accepted

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

    print(ans)


if __name__ == "__main__":
    main()