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:
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b
import itertools
from collections import Counter
from collections import defaultdict
import bisect

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

    ans = 0
    for r in range(3001):
        rest = N - r * R
        if rest < 0:
            break
        for g in range(3001):
            rest_2 = rest - g * G
            if rest_2 >= 0 and rest_2 % B == 0:
                ans += 1
                # print('r {}, g {}, b {}'.format(r, g, rest // B))
    print(ans)


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

Submission status: Accepted

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

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

print(x)

Submission status: Accepted

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

count = 0

len_r = N // R + 2
for ix in range(len_r):
    len_g = (N - (R * ix)) // G + 2
    for iy in range(len_g):
        t = N - (R * ix + G * iy)
        if t >= 0 and t % B == 0:
            count += 1
print(count)

Submission status: Accepted

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

cnt = 0

a = 3000//R


for i in range(0,a+1):
    b = (3000-R*i)//G
    for j in range(0,b + 1):
        if(R*i+G*j)<=N and (N-R*i - G*j )%B==0:

            cnt += 1
            # print(cnt)
        # if(R*i + G*j) < == N:
        #     cnt += (N-R*i + G*j )//B
        # # for k in range(0,c + 1):
        #     # if (R*i + G*j + B * k) == N:
        #     #     cnt += 1


print(cnt)

Submission status: Accepted

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

while r*R <= N:
    tank = N - r*R
    while True:
        if divmod(tank, B)[1] == 0:
            cnt += 1
        tank -= G
        if tank < 0:
            break
    r += 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):
  d = N - R * r
  for g in range(d // G + 1):
    dd = d - G * g
    if dd == 0 or (dd > 0 and dd % B == 0):
      ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = raw_input().split()
M = [0]*3
M[0] = int(l[0])
M[1] = int(l[1])
M[2] = int(l[2])
N = int(l[3])
M.sort()

#print(M, N)

count = 0

for i in range(N / M[2] + 1):
    remain1 = N - i * M[2]
 #   print('i', i, remain)
    for j in range(remain1 / M[1] + 1):
        remain2 = remain1 - j * M[1]
#        print('j', j, remain)
        if remain2 % M[0] == 0:
#            print('ans', remain2 / M[0], j, i)
            count += 1

print(count)

Submission status: Accepted

Solution code:
def main():
    R, G, B, N = [int(n) for n in input().split()]
    res = 0
    for r in range(3001):
        for g in range(3001):
            RG = R *r + G * g
            if RG > N:
                break
            elif (N - RG) % B == 0:
                res += 1
    print(res)

main()

Submission status: Accepted

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

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

buyR = int(N/R)
N1 = 0
count = 0


for i in range(buyR+1):
    N1 = N - i*R
    for j in range(int(N1/G)+1):
        if N1 - j*G >= 0:
            if (N1-j*G)%B == 0:
                count += 1

print(count)

Submission status: Accepted

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

R, G, B, N = s_inpl()

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
R, B, G, N = map(int,input().split())
 
 
cnt = 0
ball = 0
a = sorted([R,G,B])
for r in range(N//a[0]+1):
    ball = r*a[0]
    for b in range((N-ball)//a[1]+1):
        if N-ball >= 0 and (N-ball-b*a[1])%a[2] == 0:
            cnt += 1
 
print(cnt)

Submission status: Accepted

Solution code:
import sys
import random
import itertools
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
r,g,b,n = map(int,input().split())
ans = 0
for i in range(n+1):
    noko = n-r*i
    if noko < 0:
        break
    for j in range(n+1):
        noko = n-r*i
        noko = noko - g*j
        if noko < 0:
            break
        if noko % 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:
            p = n - r*R - g*G
            if p%B == 0:
                ans += 1
                #print(r,g,p//B)



print(ans)

Submission status: Accepted

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

org_list = [R, G, B]
org_list.sort()
first_num = org_list[2]
second_num = org_list[1]
third_num = org_list[0]

count = 0

for i in range(N // first_num + 1):
  for j in range((N-i*first_num) // second_num + 1):
    if (N - i*first_num - j*second_num) % third_num == 0:
      count += 1
 
print(count)

Submission status: Accepted

Solution code:
R, G, B, N = map(int, input().split())
ans = 0
zi = N // B
ans = 0
for b in range(zi + 1):
    y = (N - B * b)
    gi = y // G
    for g in range(gi + 1):
        x = y - G * g
        if x % R == 0:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import collections as c
ip = lambda : map(int, input().split())

##############
r,g,b,n = ip()
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:
from sys import stdin
import math
import itertools


def makeIntMatrix(lines):
    intMatrix = []
    for a in makeStringMatrix(lines):
        intMatrix.append([int(b) for b in a])
    return intMatrix
 
 
def makeStringMatrix(lines):
    stringMatrix = [line.split() for line in lines]
    return stringMatrix
 
 
def makeInt(line):
    return int(line.rstrip())
 
 
def makeMultiInteger(line):
    return [int(x) for x in line.rstrip().split()]


def solve(input_string):
    r, g, b, n = makeMultiInteger(input_string[0])
    c = 0
    nr = int(n/r)+1
    ng = int(n/g)+1
    nb = int(n/b)+1
    #print(r, g, b, n, nr, ng, nb)
    # 二分探索？
    """
    for i in range(nr):
        _sum = i*r
        if _sum == n:
            c += 1
            break
        for j in range(ng):
            _sum = j*g+i*r
            if _sum == n:
                c += 1
                break
            for k in range(nb):
                _sum = i*r + j*g + k*b
                #print(_sum)
                if _sum == n:
                    c += 1
                    break
    """
    for i in range(nr):
        _sum = i*r
        if _sum > n:
            break
        for j in range(ng):
            _sum = j*g+i*r
            if _sum > n:
                break
            rg_sum = j*g+i*r
            if (n - rg_sum) % b == 0:
                c += 1
            """
            for k in range(nb):
                _sum = i*r + j*g + k*b
                #print(_sum)
                if _sum == n:
                    c += 1
                    break
            """
    return c


def main():
    input_lines = stdin.readlines()
    answer = solve(input_lines)
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
r,g,b,n=map(int,input().split())
lista = [r,g,b]
lista.sort()
l = lista[-1]
m = lista[-2]
s = lista[-3]
ans = 0
for i in range((n//l)+1):
    for j in range(((n-i*l)//m)+1):
        if (n-i*l-j*m)%s==0:
            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):
    # print((i, j))
    t = n - i*r - j*g
    # print(t)
    if t >= 0 and t % b == 0:
      c += 1
print(c)

Submission status: Accepted

Solution code:
#問題B
import numpy as np
R, G, B, N= map(int, input().split())

A=[R,G,B]
A.sort()
A=np.array(A)

count=0

shou_max = N//A[2]
warukazu2 = np.arange(0, shou_max+1)
A3 = N-warukazu2*A[2]

for x in A3:
    shou_max = x//A[1]
    warukazu1 = np.arange(0, shou_max+1)
    A2 = x-warukazu1*A[1]
    
    count+=np.sum(A2%A[0]==0)
#     A2*A[0]==0
#     for y in A2:
#         if y%A[0]==0:
#             count+=sum_
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

r = int(r)
g = int(g)
b = int(b)
n = int(n)

max_r = n // r

count = 0

for ir in range(max_r + 1):
    remaining = n - r * ir
    max_g = remaining // g
    for ig in range(max_g + 1):
        remaining = n - r * ir - g * ig
        if remaining % b == 0:
            count += 1

print(count)

Submission status: Accepted

Solution code:
# coding:utf-8


def main():
    R, G, B, N = map(int, input().split())
    ans = 0
    rgb_list = [R, G, B]
    rgb_list.sort()
    for r in range(int(N/rgb_list[-1])+1):
        tempN = N - r * rgb_list[-1]
        # print(r)
        if tempN == 0:
            ans += 1
            # print(r, 0, 0)
            continue
        for g in range(int(N/rgb_list[-2])+1):
            # print(g)
            tempN2 = tempN - g * rgb_list[-2]
            if tempN2 == 0:
                ans += 1
                continue
            elif tempN2 < 0:
                break
            else:
                if tempN2 % rgb_list[0] == 0:
                    ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
R, G, B, N = (int(i) for i in input().split())
numofpattern = 0
for i in range(1+(N // R)):
    for j in range(1+((N - i * R) // G)):
        if (N-i*R-j*G) % B == 0:
            numofpattern += 1
print("{}".format(numofpattern))

Submission status: Accepted

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

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 = 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 = map(int, input().split())
number = [R, G, B]
number = sorted(number)
M = N // number[2]
ans = 0

if number[2] == 1:
    print((N+2)*(N+1)//2)
else:
    for i in range(0, M+1):
        value1 = i * number[2]
        L = (N-value1) // number[1]
        for j in range(0, L+1):
            value2 = j * number[1]
            if N-value1-value2 >= 0 and (N-value1-value2) % number[0] == 0:
                ans += 1
                continue
    
    print(ans)

Submission status: Accepted

Solution code:
r, g, b, n = map(int, input().split())
dp = [0 for _ in range(n + 1)]
dp[0] = 1
for d in [r, g, b]:
    for i in range(d, n + 1):
        dp[i] = dp[i] + dp[i - d]
print(dp[n])

Submission status: Accepted

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

total = 0

for r in range(N // R + 1):
    for g in range((N - r * R) // G + 1):
        #print([r, g, N - r * R - g * G, (N - r * R - g * G) % B])

        if (N - r * R - g * G) >= 0 and (N - r * R - g * G) % B == 0:
            #print('count!')
            total += 1

print(total)

Submission status: Accepted

Solution code:
import math


def solve():
    count = 0
    R, G, B, N = map(int, input().split())
    # print(math.floor(N / R))
    for r in range(math.floor(N / R) + 1):
        # print('G購入上限:', math.floor(((N - (R * r)) / G)))
        for g in range(math.floor(((N - (R * r)) / G)) + 1):
            if (N - (R * r) - (G * g)) % B == 0:
                # print('残数:', N - (R * r) - (G * g))
                # print(r, g, (N - (R * r) - (G * g)) / B)
                count += 1
    print(count)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

print(counter)

Submission status: Accepted

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

r, g, b = sorted([r, g, b])

ans = 0
divb = int(n / b)
for i in range(divb+1):
    remain_n1 = n - b * i
    divg = int(remain_n1 / g)
    for j in range(divg+1):
        remain_n2 = remain_n1 - g * j
        if remain_n2 % r == 0:
            ans += 1

print(ans)

Submission status: Accepted

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

sum = 0
R_G_B = [R,G,B]
R_G_B.sort()
for i in range(N // R_G_B[2] + 1):
	for j in range((N - i * R_G_B[2]) // R_G_B[1] + 1):
		if (N - R_G_B[2] * i - R_G_B[1] * j) % R_G_B[0] == 0:
			sum += 1
			
print(sum)

Submission status: Accepted

Solution code:
RGBN = [int(i) for i in input().split()]
RGB = []
for i in range(3):
    RGB.append(RGBN[i])
RGB.sort()
N = RGBN[3]

count = 0
r = 0
g = 0
b = 0
for i in range(int(N/RGB[0])+1):
    for j in range(int((N-i*RGB[0])/RGB[1])+1):
        if (N - i*RGB[0] - j*RGB[1]) % RGB[2] == 0:
            count += 1

print(count)

Submission status: Accepted

Solution code:
s = input().split(" ")
s = [int(s[i]) for i in range(len(s))]
R = s[0]
G = s[1]
B = s[2]
N = s[3]

# r + g + b = n
# r = 0 , 1 ,2, ... n
# r = k(0 <= k <= R)の時　g + b = n - k 
# g = l(0 <= l <= min(n - k , G))の時 b = n - k - l(１通り)
#よって、sum(n - k + 1)
rst = 0
for k in range(int(N / R) + 1) : 
    for l in range(int( (N - k*R) / G) + 1) : 
        if (N - k * R - l * G) % B == 0  : 
            rst += 1
print(rst)

Submission status: Accepted

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

Submission status: Accepted

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

cd = collections.defaultdict
memo = cd(lambda: cd(int))


def dfs(res, color):
    if res < 0:
        return 0
    elif res == 0:
        return 1
    elif memo[res][color] == 0:
        if color == 0:
            memo[res][color] = dfs(res - R, 0) + dfs(res - G, 1) + dfs(
                res - B, 2)
        elif color == 1:
            memo[res][color] = dfs(res - G, 1) + dfs(res - B, 2)
        elif color == 2:
            memo[res][color] = dfs(res - B, 2)
    return memo[res][color]


print(dfs(N, 0))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
R, G, B, N = map(int, input().split())
a = N // R
t = 0
for i in range(a + 1):
    b = N - R*i
    c = b // G
    for l in range(c + 1):
        d = b - G*l
        if d % B == 0:
            t += 1
print(t)

Submission status: Accepted

Solution code:
R,G,B,N=map(int,input().split())
way=[R,G,B]
box=0
way.sort(reverse=True)
MAX=way[0]
SECOND=way[1]
MIN=way[2]
ways=int((N-N%MAX)/MAX)
for i in range(0,ways+1):
    sum=N-MAX*i
    way_2=int((sum-sum%SECOND)/SECOND)
    for j in range(0,way_2+1):
        sum_2=sum-SECOND*j
        if sum_2%MIN==0:
            box+=1
print(box)

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) // B + 1):
    rest = n - i * R - j * B
    if rest % G == 0 :
      ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
red, green, blue, total = map(int, input().split(' '))

available_balls = [red, green, blue]
available_balls.sort(reverse=True)

num_combination = 0
for zero in range(0, (total // available_balls[0]) + 1):
    mod_ball = total - zero * available_balls[0]
    for one in range(0, (mod_ball // available_balls[1]) + 1):
        rest_ball = mod_ball - one * available_balls[1]
        
        if rest_ball % available_balls[2] == 0:
            num_combination += 1
            
        # if rest_ball % available_balls[2] == 0:
        #     two = rest_ball // available_balls[2]
        #     print(f"({zero}, {one}, {two}) == OK!")
        #     num_combination += 1
        # else:
        #     two = rest_ball // available_balls[2]
        #     print(f"({zero}, {one}, {two}) -- NG")

print(num_combination)

Submission status: Accepted

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

i,j,k = 0,0,0

ans = 0



while True:
	temp = i * r
	j,k = 0,0
	if(temp > n):
		break
	while True:
		temp = i * r + j * g
		k = 0
		if(temp > n):
			break
		if((n - temp)%b == 0):
			ans+= 1
		j+= 1
	i += 1

print(ans)

Submission status: Accepted

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

count=0
for ri in range(int(n/r)+1):
    for gi in range(int((n-ri*r)/g)+1):
        sumc=n-ri*r-gi*g
        if sumc<0:
            break
        if sumc%b==0:
            count+=1

print(count)

Submission status: Accepted

Solution code:
R,G,B,N=(int(i) for i in input().split())
import math
answer=0
for r in range(0,math.floor(N/R)+1):
    for g in range(math.floor(N/G)+1):
        sss=R*r+G*g
        if sss>N:
            break
        if (N-sss)%B==0:
            answer+=1
print(answer)

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
from types import GeneratorType

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 bootstrap(f, stack=[]):
    def wrappedfunc(*args, **kwargs):
        if stack:
            return f(*args, **kwargs)
        else:
            to = f(*args, **kwargs)
            while True:
                if type(to) is GeneratorType:
                    stack.append(to)
                    to = next(to)
                else:
                    stack.pop()
                    if not stack:
                        break
                    to = stack[-1].send(to)
            return to

    return wrappedfunc


def memodict(f):
    """ Memoization decorator for a function taking a single argument. """

    class memodict(dict):
        def __missing__(self, key):
            ret = self[key] = f(key)
            return ret

    return memodict().__getitem__


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


    print(sum((n - (i + j)) % b == 0 for i in range(0, n + 1, r) for j in range(0, (n - i) + 1, g)))


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

N = INPUT.pop(3)
INPUT.sort()

res = 0
for i in range(N//INPUT[2]+1):
    remainder_1 = N-INPUT[2]*i
    for j in range(remainder_1//INPUT[1]+1):
        remainder_2 = remainder_1-INPUT[1]*j
        if remainder_2%INPUT[0] == 0:
            res += 1

print(res)

Submission status: Accepted

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

cnt = 0
for k in reversed(range(N // R + 1)):
  if N - k * R == 0:
    cnt += 1
    continue
  N1 = N - k * R
  for i in reversed(range(N1 // G + 1)):
    if N1 - i * G == 0:
      cnt += 1
      continue
    N2 = N1 - i * G
    if N2 % B == 0:
      cnt += 1
    else:
      continue
print(cnt)

Submission status: Accepted

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


count = 0
for i in range(3001):
    for j in range(3001):
        r = R * i
        g = G * j
        b = N - r - g
        if b % B != 0:
            continue
        if r + g + b == N and r >= 0 and g >= 0 and b >= 0:
            count += 1

print(count)

Submission status: Accepted

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

pat = 0
for r in range(N//R+1):
    rest = N - R*r
    for b in range(rest//B+1):
        if (rest-B*b) % G == 0:
            pat += 1
print(pat)

Submission status: Accepted

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


def solve():
    count = 0
    for r in range(0, N+1, R):
        rem = N - r
        count += sum(1 if (rem-g)%B == 0 else 0 for g in range(0, N-r+1, G))

    print(count)


#R, G, B, N = 13, 1, 4, 3000
#R, G, B, N = 1,2,3,4
solve()

Submission status: Accepted

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

ans = 0
for r in range(N//R+1):
    tmp_N = N - r*R
    for g in range(tmp_N//G+1):
        tmp_tmp_N = tmp_N - g*G
        if tmp_tmp_N%B == 0:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    r, g, b, n = map(int, input().split())
    ans = 0
    rgb = sorted([r,g,b], reverse=True)
    if rgb[1] == 1 and rgb[2] == 1:
        for i in range(n//rgb[0]+1):
            ans += (n-i*rgb[0]+1)
        print(ans)
        exit()
    for i in range(n//rgb[0]+1):
        for j in range((n-i*rgb[0])//rgb[1]+1):
            if (n-i*rgb[0]-j*rgb[1])%rgb[2]==0:
                ans+=1
    print(ans)

Submission status: Accepted

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

r = N // R
g = N // G
b = N // B

c = 0
for i in range(r+1):
    for j in range(g+1):
        n = N - i*R - j*G
        if n < 0:
            continue
        if n % B == 0:
            c += 1

print(c)

Submission status: Accepted

Solution code:
rgb = [ int(x) for x in input().split() ]
n = rgb.pop()
r,g,b = sorted( rgb,key=lambda x:-x )

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

Submission status: Accepted

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

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

print(res)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin
import numpy as np
 
R, G, B, N = map(int,input().split())

lst = sorted([R, G, B], reverse=True)


cnt = 0
var_1 = N
while True: #一番高いものを買う
  var_2 = var_1
  while True: #二番目に高いものを買う
    if var_2 % lst[2] == 0:
      cnt += 1
    var_2 -= lst[1]
    if var_2 < 0:
      break
  var_1 -= lst[0]
  if var_1 < 0:
    break
    
print(cnt)

Submission status: Accepted

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


def solve(R: int, G: int, B: int, N: int):
    cnt= 0
    for r in range(0, N + 1, R):
        upper = N + 1 - r
        for g in range(0, upper, G):
            temp = upper-1-g
            if temp < 0:
                break
            b = temp / B
            if b % 1 == 0 and b >= 0:
                cnt += 1
            else:
                continue
    print(cnt)
    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:
red, green, blue, n = map(int, input().split())
ret = 0
for r in range(n + 1):
    for g in range(n + 1):
        b = n - r * red - g * green
        if b >= 0 and b % blue == 0:
            ret += 1
print(ret)

Submission status: Accepted

Solution code:

# coding: utf-8

# In[3]:

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


# In[14]:

cnt = 0
a, b, c = sorted([R, G, B], reverse=True)
#print(a, b, c)
#print(N//a)
for i in range(N//a+1):
    for j in range((N-a*i)//b+1):
        tmp = N-a*i-b*j
        if tmp%c == 0:
            #print('{}*{} + {}*{}'.format(a, i, b, j))
            cnt += 1
print(cnt)


# In[19]:

list(range(1//3 + 1))


# In[ ]: