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

Submission status: Accepted

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

nr = n // r
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import sys
r, g, b, n = [int(i) for i in sys.stdin.readline().split()]
memo_ls = [[0 for j in range(n+1)] for i in range(4)]
memo_ls[0][0] = 1
for i, color in enumerate(sorted([r, g, b]), 1):
    for j in range(n + 1):
        if j >= color:
            memo_ls[i][j] = memo_ls[i-1][j] + memo_ls[i][j-color]
        else:
            memo_ls[i][j] = memo_ls[i-1][j]
print(memo_ls[-1][-1])

Submission status: Accepted

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

print(ans[n])

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

Submission status: Accepted

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

ans=0
for r in range(0,N+1,R):
  for g in range(0,N+1,G):
    if r+g>N: break
    b=N-r-g
    if b%B==0:
      ans+=1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
R, G, B, N = map(int, input().split())
ans = 0
for r in range(N//R+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:
z=input().strip().split()
R=int(z[0])
B=int(z[1])
G=int(z[2])
N=int(z[3])
count=0
n=N
while n>=0:
  copy=n
  while n>=0:
    if n%G==0:
      count+=1
    n-=B
  n=copy-R
print(count)

Submission status: Accepted

Solution code:
A=[0]*3
A[0],A[1],A[2],N=map(int,input().split())
A.sort()
ret=0
for i in range(N//A[2]+1):
  n=N-A[2]*i
  for j in range(n//A[1]+1):
    if (n-j*A[1])%A[0]==0:
      ret+=1
print(ret)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""
O(N^2)
"""
#solution:
#潜 影 蛇 手 ! !
*c,N=pin()

ans=0


I=(N//c[0])+1
J=N//c[1]+1
for i in range(I):
    for j in range(J):
        remain=(N-i*c[0]-j*c[1])
      
        if remain>=0 and remain%c[2]==0:
            
            ans+=1
            
print(ans)
#print(["NO","YES"][1-cond])
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])

Submission status: Accepted

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

Submission status: Accepted

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

ans=0
for r in range(3333):
    for g in range(3333):
        rest = N - (r*R+g*G)
        if rest<0:
            break
        if rest % 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):
        sum = i + j
        if N - sum < 0:
            break
        elif (N - sum) % B == 0:
            count += 1
 
print(count)

Submission status: Accepted

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

r = 0
I = n//a3+1
for i in range(I):
    for j in range((n-i)//a2+1):
        t = n-i*a3-j*a2
        if t>=0 and t%a1==0:
            r += 1
print(r)

Submission status: Accepted

Solution code:
r,g,b,n = [int(i) for i in input().split()]
ans = 0
 
for i in range(0,n+1,r):
    for j in range(0,n+1,g):
        total = i + j
        if n - total < 0:
            break
        elif (n - total) % b == 0:
            ans += 1
 
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

li = [R,G,B]
li.sort()
R = li[0]
G = li[1]
B = li[2]
#print(R,G,B)

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

Submission status: Accepted

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

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

    print(ct)

if __name__ == "__main__":
    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-r*R)//G+1):
        b = (n-r*R-g*G)//B
        if r * R + g * G + b * B == n:
            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+1):
        if ((n - (r*(i) + g*(j))) >= 0) and ((n - (r*(i) + g*(j))) % b == 0):
            cnt += 1
            #print(i)
            #print(j)
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 // G + 1):
        b = (N - R * r - G * g) / B
        if b == int(b) and 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):
    d = n - r*i - g*j
    if d%b == 0 and d >= 0:
      count += 1
print(count)

Submission status: Accepted

Solution code:
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6)
input=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-i):
            now=(n-i*r-j*g)//b
            if now>=0 and (n-i*r-j*g)%b==0:
                ans+=1
    print(ans)

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
# N, K = map(int, input().split())
# a = map(int, input().split())

R,G,B,N = map(int, input().split())
count = 0
for i in range(0, N + 1, R):
    K = N - i

    for j in range(0, K + 1, G):
        J = K - j

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

Submission status: Accepted

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

B,G,R = sorted([R,G,B])

ans = 0
for r in range(N//R + 1):
  for g in range(N//G + 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:
import collections
import itertools
r,g,b,n=map(int,input().split())
x,y=n//r,n//g
x,y=list(range(0,r*x+1,r)),list(range(0,g*y+1,g))
l=[i+j for i,j in itertools.product(x,y) if i+j<=n]
z=collections.Counter(l)
count=0
for key,value in zip(z.keys(),z.values()):
  v=n-key
  if v==0:
    count+=value
  elif v%b==0:
    count+=value
print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

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):
        Bb = N - R * r - G * g
        if Bb >= 0 and Bb % 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):
  num=n-R*r-G*g
  if num>=0 and num%b==0:
   cnt+=1
print(cnt)

Submission status: Accepted

Solution code:
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):
            now = N - R*i - G*j
            if now%B==0 and now>=0:
                ans += 1

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

def main():
    point = 0
    r,g,b,n = [int(x) for x in stdin.readline().rstrip().split()]
    for i in range(n//r+1):
        for j in range((n-r*i)//g+1):
            if n-r*i-g*j >= 0:
                if (n-r*i-g*j)%b == 0:
                    point += 1
    print(point)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

solve()

Submission status: Accepted

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

solve()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

solve()

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

Submission status: Accepted

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

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

    cnt = 0
    for i in range(int(n//r)+1):
        r_num = r * i
        for j in range(int((n - r_num)//g)+1):
            g_num = g * j
            b_num = (n - r_num - g_num)
            if b_num >= 0 and b_num % 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(int(n//r)+1):
    r_num = r * i
    for j in range(int((n - r_num)//g)+1):
        g_num = g * j
        b_num = (n - r_num - g_num)
        if b_num >= 0 and b_num % 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+1):
    x=n-r*i
    for j in range(x+1):
        y=x-g*j
        if y>=0 and 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(n//r+1):
   for j in range((n-i*r)//g + 1):
      rest = n  - i * r
      rest -= j * g
      if rest % 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+1):
    for j in range(n+1):
        z = r * i + g * j
        if z <= n and (n - z) % 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+1):
    x = n - r * i
    for j in range(x+1):
        y = x - g * j
        if y >= 0 and y % b == 0:
            ans += 1
print(ans)

Submission status: Accepted

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

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  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):
      tmp=r*i+g*j
      q,mod=divmod(n-tmp,b)
      if (q>=0 and mod==0):
        cnt+=1
  print(cnt)
  
main()

Submission status: Accepted

Solution code:
def main():
  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):
      tmp=r*i+g*j
      q,mod=divmod(n-tmp,b)
      if (q>=0 and mod==0):
        cnt+=1
  print(cnt)
  
main()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
R,G,B,N = map(int,input().split())
a = 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:
      a += 1
print(a)

Submission status: Accepted

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

count = 0
a = n // r
t = n // g

for i in range(a+1):
    for j in range(t+1):
        rg = i * r + j * g
        rest = n - rg
        if rest < 0:
            continue
        elif rest % b == 0:
            count += 1

print(count)

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

print(answer)

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
import numpy as np

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

R, G, B, N = rl()
UP = 3000
A = np.zeros(UP+1, dtype=np.int32)

for r in range(UP+1):
    if r * R > UP:
        break
    A[r*R::G] += 1

answer = A[N::-B].sum()
print(answer)
#08

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

R, G, B, N = rl()
answer = 0
for r in range(N//R + 1):
    sum = r * R
    for g in range((N-sum)//G + 1):
        sum2 = sum + g * G
        if (N-sum2)%B == 0:
            answer += 1

print(answer)
#45

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
R, G, B, N = map(int, input().split(' '))
ans = 0

import math
r_lim = int(math.ceil(N / R))
for r in range(0, r_lim + 1):
    n = N - R * r

    g_lim = int(math.ceil(n / G))
    for g in range(0, g_lim + 1):
        m = n - g * G
        if m >= 0 and m % B == 0:
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
R,G,B,N = map(int,input().split())
cnt = 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:
            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+1):
            if (N - R*i - G*j) % B == 0 and (N - R*i - G*j) > 0:
                cnt += 1
                # print(str(i) + " " + str(j) + " " + str)
            if N == R*i + G*j:
                cnt += 1

print(cnt)

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
R,G,B,N=map(int,input().split())
dp=[0]*(N+1)
dp[0]=1
for C in (R,G,B):
  for i in range(len(dp)-C):
    if dp[i]!=-1:
        dp[i+C]=dp[i]+dp[i+C]
print(dp[N])

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# B - RGB Boxes
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
R,G,B,N = map(int, input().split())
ans = 0
for r in range(3001):
    for g in range(N-r+1):
        t = N-(R*r+g*G)
        if t>=0 and t%B==0:
            ans += 1
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
R, G, B, N = map(int, input().split())
count = 0
# print(N//R+1)
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:
            count += 1
    # print(i, (N-i) // G+1)
print(count)

Submission status: Accepted

Solution code:
from sys import stdin
R, G, B, N = [int(_) for _ in stdin.readline().rstrip().split()]
ans = 0
for i in range(3001):
  for j in range(3001):
    tmp = i*R+j*G
    if N >= tmp and (N-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(0, N // R + 1):
    _g = N - R * r
    for g in range(0, _g // G + 1):
        _b = N - R * r - G * g
        if _b % B == 0:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys

#+++++
		
def main():
	R,G,B,N = map(int, input().split())
	cc=0
	ri=0
	while ri * R <= N:
		gi=0
		while G*gi + ri*R <= N:
			nn=N-(G*gi+R*ri)
			if nn % B == 0:
				cc+=1
			gi+=1
		ri+=1
	
	print(cc)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

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

for a in range(n+1):
  for c in range(n+1):
    Bb = n - r*a - g*c
    if Bb >= 0:
      if Bb % b == 0:
        count += 1
    else:
      break

print(count)

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

# N = int(sys.stdin.readline())
# P = [int(sys.stdin.readline()) for _ in range(N)]
#
# P = np.array(P, dtype=int)
#
# ans = 0
# while np.all(P % 10 == 0):
#     P //= 10
#     ans += 1
# print(ans)

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

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 == 0 or b > 0 and b % B == 0:
            ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = list(map(int, input().split()))

R = num[0]
G = num[1]
B = num[2]
N = num[3]
ans = 0

rmax = N // R

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

Submission status: Accepted

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

for r in range(N+1):
  for g in range(N+1):
    Bb=N-R*r-G*g
    if Bb>=0:
      #print(r,g,Bb)
      if Bb%B==0:
        count+=1
    else:
      break
      
print(count)

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b,c,n = inpl()
res = 0
for i in range(3001):
    for j in range(3001):
        tmp = n - (i*a + j*b)
        if tmp < 0:
            break
        if tmp % c == 0:
            res += 1
print(res)

Submission status: Accepted

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

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:
r,g,b,n=map(int,input().split())
l=[r,g,b,n]
count=0
for i in range(n+1):
  for j in range(n+1):
    if (n-(i*r+j*g))/b==int((n-(i*r+j*g))/b) and (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(1+n//r):
    for j in range(1+n//g):
        if (n-r*i-g*j)%b==0 and n-r*i-g*j>=0:
            ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    r, g, b, n = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    for i in range(n+1):
        for j in range(n+1):
            if r * i + g * j > n:
                break
            else:
                if (n - r * i - g * j) % b == 0:
                    cnt += 1
    print(cnt)


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):
    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:
def main():
    a,b,c,n=map(int,input().split())
    res = 0
    l = [a,b,c]
    l.sort()
    for i in range(n // l[2]+1):
        for j in range(n//l[1]+1):
            if n < l[2]*i+l[1]*j:
                break
            if (n - l[2] * i - l[1] * j ) % l[0] == 0:
                res += 1
    print(res)

main()

Submission status: Accepted

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