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: Wrong Answer

Solution code:
R, G, B, N = map(int, input().split())
number = [R, G, B]
number = sorted(number)
M = N // number[2]
ans = 0

if N>3 and number[2] == 1:
    print((N+3)*(N+2)*(N+1)//6)
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: Wrong Answer

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

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

ans = 0
divb = n // b
for i in range(divb+1):
    remain_n1 = n - b * i
    divg = 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: Wrong Answer

Solution code:
import numpy as np
R, B, G, N = (int(x) for x in input().split())
a = np.array([R, B, G])
a = np.sort(a)
b = a[2]
d = a[1]
c = int(N / b)

count = 0

for i in range(c + 1):
    n = N - b * i
    e = int(n / d)
    for j in range(e + 1):
        m = n - d * j
        count += 1

print(count)

Submission status: Wrong Answer

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:
            cnt+=1
        if R*i+G*j>=N:
            break
    if R*i>=N:
        break

print(cnt)

Submission status: Wrong Answer

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

ans = x = y = z = 0

# R*x + G*y + B*z = N

for x in range(100):
    for y in range(100):
        for z in range(100):
            if R*x + G*y + B*z > N:
                break
            elif R*x + G*y + B*z == N:
                ans += 1

print(ans)

Submission status: Wrong Answer

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


cnt = 0
ball = 0
a = sorted([R,G,B],reverse=True)
for r in range(N//a[0]+1):
    ball = r*a[0]
    for b in range((N-ball)//a[1]+1):
        ball += b*a[1]
        # for g in range((N-ball)//a[2]+1):
        if (N-ball)%a[2] == 0:
            cnt += 1
            # print(r,b,g)
print(cnt)

Submission status: Wrong Answer

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

sum = 0
count = 0

len_R = N // R + 1
len_G = N // G + 1
len_B = N // B + 1

for ix in range(N // R + 2):
    for iy in range(N // G + 2):
        sum = N - (R * ix + G * iy)
        if sum % B == 0:
            count += 1
        sum = R * ix + G + iy
        if sum > N:
            break
    sum = R * ix
    if sum > N:
        break

print(count)

Submission status: Wrong Answer

Solution code:
def a(R,G,B,N):
  b=0
  for r in (1,R+1):
    for g in (1,G+1):
      for b in (1,B+1):
        if r+g+b==N:
          b+=1
  return b

Submission status: Wrong Answer

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

ans = x = y = z = 0

# R*x + G*y + B*z = N

for x in range(100):
    for y in range(100):
        for z in range(100):
            print("hogee")
            if R*x + G*y + B*z > N:
                break
            elif R*x + G*y + B*z == N:
                ans += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
def s(N,K):
  a=math.factorial(N)/(math.factorial(K)*math.factorial(N-K))
  return a
 
def a(R,G,B,N):
  for r in (1,R+1):
    for g in (1,G+1):
      for b in (1,B+1):
        if r+g+b==N:
          b=s(R,r)*s(G,g)*s(B,b)
  return b

Submission status: Wrong Answer

Solution code:
R, G, B, N = map(int, input().split())
number = [R, G, B]
number = sorted(number)
M = N // number[2]
ans = 0

if N>3 and number[2] == 1:
    print(N*(N-1)*(N-2)//6)
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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
def s(N,K):
  a=math.factorial(N)/(math.factorial(K)*math.factorial(N-K))
  return a
 
def a(R,G,B,N):
  for r in range(R):
    for g in range(G):
      for b in range(B):
        if r+g+b==N:
          b=s(R,r)*s(G,g)*s(B,b)
  return b

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

R,G,B,N =[int(x) for x in input().split()]
count = 0
for i in range(N//R):
    for j in range((N-i*R)//G):
        for k in range((N-i*R-j*G)//B):
            
            if i*R+j*G+k*B == N:
                count += 1

print(count)

Submission status: Wrong Answer

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>=0 and tmp%c == 0:
            #print('{}*{} + {}*{}'.format(a, i, b, j))
            cnt += 1
print(cnt)


# In[ ]:

Submission status: Wrong Answer

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

m1 = max(r, g, b)
m3 = min(r, g, b)
m2 = r+g+b-(m1+m3)

l1 = [m1*i for i in range(0, n//m1 +1)]
cnt = 0
for x in l1:
    for i in range(0, (n-x)//m2 +1):
        if x+m2*i <= n:
            if (x+m2*i) % m3 == 0:
                cnt += 1
        else:
            break
            
print(cnt)

Submission status: Wrong Answer

Solution code:
a,b,c,n = map(int,input().split())
ans = 0
x,y,z = 0,0,0
while a*x <= n:
  m = n-a*x
  y = 0
  f = 0
  while m-b*y>= 0 and y < c:
    if (m-b*y)%c == 0:
      f = 1
      break
    y += 1
  ans += f*((m-b*y)//c//b+1)
  x += 1
print(ans)

Submission status: Wrong Answer

Solution code:
# def gcd(a_gcd, b_gcd):
#     while b_gcd != 0:
#         a_gcd, b_gcd = b_gcd, a_gcd % b_gcd
#     return a_gcd
#
#
# def lcm(a_lcm, b_lcm):
#     return a_lcm * b // gcd(a_lcm, b_lcm)
#
#
# def max_sum(N_max_sum, a_max_sum):
#     dp = [0] * (N_max_sum + 1)
#     for i in range(N_max_sum):
#         dp[i + 1] = max(dp[i], dp[i] + a_max_sum[i])
#     return dp[N]
#
#
# def knapsack(N_knapsack, W, weight, value):
#     inf = float("inf")
#     dp = [[-inf for _ in range(W+1)] for j in range(N_knapsack + 1)]
#     for i in range(W+1):
#         dp[0][i] = 0
#
#     for i in range(N_knapsack):
#         for w in range(W+1):
#             if weight[i] <= w:
#                 dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
#             else:
#                 dp[i+1][w] = dp[i][w]
#     return dp[N_knapsack][W]


# # s = input()
# # N = int(input())
# N, K = map(int, input().split())
# # b = list(map(int, input().split()))
# # c = [list(map(int, input().split())) for _ in range(N)]
#
#
#
# print(N-K+1)

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

if B > R:
    B, R = R, B
if B > G:
    B, G = G, B

for r_i in range(N + 1):
    if r_i * R > N:
        break
    for g_i in range(N + 1):
        if r_i * R + g_i * G > N:
            break
        if (N - (r_i * R + g_i * G)) % B == 0:
            ans += 1 + (N - (r_i * R + g_i * G)) // G
            break

print(ans)

Submission status: Wrong Answer

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

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

l = []
l.append(r)
l.append(g)
l.append(b)

l.sort(reverse = True)

cnt = 0
for i in range(n//l[0]+1):
    sum = i*l[0]

    for j in range((n-sum)//l[1]+1):
        sum = sum + j*l[1]

        if (n - sum)%l[2] == 0:
            cnt = cnt +1

print(cnt)

Submission status: Wrong Answer

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

cnt = 0
for i in range(n//r+1):
  n_r = i*r
  if n_r > n:
    break
  for j in range(n//g+1):
    n_rg = j*g + n_r
    if n_rg > n:
      break
    if n_rg%b == 0:
      cnt += 1
        
print(cnt)

Submission status: Wrong Answer

Solution code:

# coding: utf-8

# In[3]:

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


# In[13]:

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):
        if (N-a*i+b*j)%c == 0:
            #print('{}*{} + {}*{}'.format(a, i, b, j))
            cnt += 1
print(cnt)


# In[ ]:

Submission status: Wrong Answer

Solution code:
from fractions import gcd

r, g, b, n = map(int, input().split())
ans = 0
d = g * b // gcd(g, b)
for i in range(n // r + 1):
    gb = n - r * i
    if (gb % d) % g == 0 or (gb % d) % b == 0:
        ans += gb // d + 1
print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,n = map(int,input().split())
ans = 0
x,y,z = 0,0,0
while a*x <= n:
  m = n-a*x
  y = 0
  f = 0
  while m-b*y>= 0 and y < c:
    if (m-b*y)%c == 0:
      f = 1
      break
    y += 1
  ans += f*((m-b*y)//(b*c)+1)
  x += 1
print(ans)

Submission status: Wrong Answer

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

# print(factorial(N)/(factorial(R)*factorial(B)*factorial(G)))

cnt = 0
ball = 0
a = sorted([R,G,B],reverse=True)

for r in range(N//a[0]+1):
    ball = r*a[0]
    for b in range((N-ball)//a[1]+1):
        ball += b*a[1]
        for g in range((N-ball)//a[2]+1):
            if (N-ball)%a[2] == 0:
                cnt += 1
                # print(r,g,b)
print(cnt)

Submission status: Wrong Answer

Solution code:
from io import StringIO
from collections import *
from functools import *
import sys


def main(inputs):
    # n = int(next(inputs))
    # xs = list(map(int, next(inputs).split()))
    r, g, b, n = list(map(int, next(inputs).split()))
    ans = 0
    for i in range(1+min(r, n)):
        n_r = n - i
        if n_r < 0:
            continue
        for j in range(1+min(g, n_r)):
            n_g = n_r - j
            if n_g < 0:
                continue
            if n_g <= b:
                ans += 1
                pass
            pass
        pass
    return ans


def gen_inputs(str_=None):
    inputs = StringIO(str_) if str_ else sys.stdin
    while True:
        a = inputs.readline().rstrip()
        yield a
        pass
    pass


if __name__ == "__main__":
    print(main(gen_inputs()))
    pass

Submission status: Wrong Answer

Solution code:
R1, R2, R3, N = map(int, input().split())
lt = [R1, R2, R3]
lt.sort()

count = 0
for i in range(int(N / lt[2])+1):
	N_i = N - i * lt[2]
	for j in range(int(N_i / lt[1])+1):
		N_j = N - j * lt[1]
		if N_j % lt[0] == 0:
			count += 1
print(count)

Submission status: Wrong Answer

Solution code:
*RGB, N = map(int, input().split())
RGB.sort()
ans = 0
for i in range(N // RGB[2] + 1):
    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: Wrong Answer

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

print(cnt)

Submission status: Wrong Answer

Solution code:
a,b,c,n = map(int,input().split())
ans = 0
x,y,z = 0,0,0
while a*x <= n:
  m = n-a*x
  y = 0
  f = 0
  while m-b*y>= 0 and y < c:
    if (m-b*y)%c == 0:
      f = 1
      break
    y += 1
  ans += f
  x += 1
print(ans)

Submission status: Wrong Answer

Solution code:
R, G, B, N = map(int, input().split())
number = [R, G, B]
number = sorted(number)
M = N // number[2]
ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
#python 3.5.2

R, G, B, N = [int(s) for s in input().split()]

cnt = 0
for i in range(0, int(N/R)+1):
    for j in range(0, int(N/G)+1):
        for k in range(0, int(N/B)+1):
            print(i, j, k)
            sum = i*R + j*G + k*B
            if sum == N:
                cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
from io import StringIO
from collections import *
from functools import *
import sys


def main(inputs):
    # n = int(next(inputs))
    # xs = list(map(int, next(inputs).split()))
    r, g, b, n = list(map(int, next(inputs).split()))
    ans = 0
    for i in range(1+min(r, n)):
        n_r = n - i
        for j in range(1+min(g, n_r)):
            n_g = n_r - j
            if n_g <= b:
                ans += 1
                pass
            pass
        pass
    return ans


def gen_inputs(str_=None):
    inputs = StringIO(str_) if str_ else sys.stdin
    while True:
        a = inputs.readline().rstrip()
        yield a
        pass
    pass


if __name__ == "__main__":
    print(main(gen_inputs()))
    pass

Submission status: Wrong Answer

Solution code:
N,M,S,L=map(int,input().split())
s = 0
for i in range(L//N):
    for j in range(L//M):
        if N*i + M*j > L:
            break
        for k in range(L//S):
            if N*i + M*j + S*k > L:
                break
            if N*i + M*j + S*k == L:
                s+=1
print(s)

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7

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

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


print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
*lst,N = map(int, input().split())

lst.sort(reverse=True)
#print(lst)
count = 0
for i in range(N // lst[0] + 1):
    for j in range((N - i * lst[0]) // lst[1] + 1):
        if (N - i * lst[0]) % lst[2] == 0:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:

# coding: utf-8

# In[1]:

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


# In[2]:

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


# In[ ]:

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
r, g, b, n = map(int, input().split())
cnt = 0
nr = 0
while nr <= n:
    m = n - nr * r
    ng = 0
    while ng <= m:
        l = m - ng * g
        if not l % b:
            cnt += 1
        ng += 1
    nr += 1
print(cnt)

Submission status: Wrong Answer

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

l = [R, G, B]
l.sort()
low, mid, top = l[0], l[1], l[2]
count = 0
for a in range(N//top + 1):
  temp = N - a * top
  for b in range(temp//mid + 1):
    temp = temp - b * mid
    if temp % low == 0:
      count += 1
print(count)

Submission status: Wrong Answer

Solution code:
input = input().split()
R = int(input[0])
G = int(input[1])
B = int(input[2])
N = int(input[3])

count = 0

for r in range(N+1):
    count += 2**(N-r)

print(count)

Submission status: Wrong Answer

Solution code:
R, G, B, N = map(int, input().split())
r, g, b, ans = 0, 0, 0, 0
while R * r <= N:
  while R * r + B * b <= N:
    if (N - R * r + B * b) % G == 0:
      ans += 1
    b += 1
  b = 0
  r += 1
print(ans)

Submission status: Wrong Answer

Solution code:
R, G, B, N = [int(i) for i in input().split()]
ans = 0
for r in range(3000):
    for g in range(3000):
        mod = N - r * R - g * G
        if mod >= 0 and mod % B == 0:
            ans += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

# coding: utf-8

# In[3]:

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


# In[5]:

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


# In[ ]:

Submission status: Wrong Answer

Solution code:
R, G, B, N = map(int, input().split())
number = [R, G, B]
number = sorted(number)
M = N // number[2]
ans = 0

for i in range(0, M+1):
    value = i * number[2]
    L = (N-value) // number[1]
    for j in range(0, L+1):
        value += j * number[1]
        if (N-value) % number[0] == 0:
            ans += 1
            continue

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(i)

Submission status: Wrong Answer

Solution code:

def main():
    buf = input()
    buflist = buf.split()
    R = int(buflist[0])
    G = int(buflist[1])
    B = int(buflist[2])
    N = int(buflist[3])
    combination = 0
    for i in range(3000):
        if i * R > N:
            break
        for j in range(3000):
            if i * R + j * G > N:
                break
            if (N - (i * R + j * G)) % B == 0:
                combination += 1
    print(combination)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count = 0
for r in range(R):
  if r+1>=N: continue
  for g in range(G):
    if r+g+2>=N: continue
    for b in range(B):
      if r+g+b+3 == N:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
R,G,B,N = map(int,input().split())
ans = 0
for r in range(R+1):
  rest = N - r
  if rest < 0 or rest > G + B:
    continue
  for g in range(G+1):
    if rest - g >= 0 and rest - g <= B:
      ans += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

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

print(ans)

Submission status: Wrong Answer

Solution code:
R,G,B,N = map(int,input().split())
ans = 0
for r in range(R+1):
  rest = N - r
  if rest > G + B:
    continue
  else:
    ans += G+B - rest + 1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
colorn = list(map(int, input().split()))
color = colorn[0:3]
n = colorn[-1]
color.sort()

a, b, c = color[2], color[1], color[0]

a_max = n // a
cnt = 0

for i in range(a_max + 1):
    b_max = (n - a * i) // b
    for j in range(b_max + 1):
        c_max = (n - a * i - b * j) // c
        for k in range(c_max, c_max + 2):
            if a * i + b * j + c * k == n:
                cnt += 1
            elif a * i + b * j + c * k > n:
                break     
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
colorn = list(map(int, input().split()))
color = colorn[0:3]
n = colorn[-1]
color.sort()

a, b, c = color[2], color[1], color[0]

a_max = n // a
b_max = n // b
c_max = n // c
cnt = 0

for i in range(a_max + 1)[::-1]:
    b_max = (n - a * i) // b
    for j in range(b_max + 1)[::-1]:
        c_max = (n - a * i - b * j) // c
        for k in range(c_max + 1)[::-1]:
            if a * i + b * j + c * k == n:
                cnt += 1
            elif a * i + b * j + c * k < n:
                break     
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = [int(c) for c in input().split()]
cnt = 0
for r in range(N//R+1):
    for g in range((N-r*R)//G+1):
        for b in range((N-r*R-g*G)//B+1):
            if r*R+g*G+b*B == N:
                cnt+=1

print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

x = sorted([R, G, B])[::-1]

cnt = 0
for r in range(N//x[0]+1):
    for g in range(N//x[1]+1):
        res = N - (r*x[0]+g*x[1])
        if res >= 0 and res % x[2] == 0:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

li=[R,G,B]
ans=0
li.sort(reverse=True)


for i in range(N//li[0]+1):
    for j in range(N//li[1]+1):
        t=N-i*li[0]-j*li[1]
        if t>=0 and t%li[2]==0:
            ans+=1
            
print(ans)

Submission status: Time Limit Exceeded

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

li=[R,G,B]
ans=0
li.sort(reverse=True)


for i in range(N//li[0]+1):
    for j in range(N//li[1]+1):
        if N-i*li[0]-j*li[1]>=0 and (N-i*li[0]-j*li[1])%li[2]==0:
            ans+=1
            
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# diverta 2019 Programming Contest: B – RGB Boxes
R, G, B, N = [int(i) for i in input().split()]

bingo = 0

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

print(bingo)

Submission status: Time Limit Exceeded

Solution code:
# diverta 2019 Programming Contest: B – RGB Boxes
R, G, B, N = [int(i) for i in input().split()]

bingo = 0

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

print(bingo)

Submission status: Time Limit Exceeded

Solution code:
# diverta 2019 Programming Contest: B – RGB Boxes
R, G, B, N = [int(i) for i in input().split()]

bingo = 0

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

print(bingo)

Submission status: Time Limit Exceeded

Solution code:
# diverta 2019 Programming Contest: B – RGB Boxes
R, G, B, N = [int(i) for i in input().split()]

bingo = 0

for r in range(0, 3001):
    for g in range(0, 3001):
        b = (N -(R * r + G * g)) // B
        if b < 0:
            break
        elif R * r + G * g + B * b == N:
            bingo += 1

print(bingo)

Submission status: Time Limit Exceeded

Solution code:
# diverta 2019 Programming Contest: B – RGB Boxes
R, G, B, N = [int(i) for i in input().split()]

bingo = 0

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

print(bingo)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#19 B - RGB Boxes
R,G,B,N = map(int,input().split())
lis = sorted([R,G,B])
MA, MID, MI = lis[0],lis[1],lis[2]

cnt = 0
for ma in range(N//MA+1):
    for mid in range(N//MID+1):
        mi = (N - (MA*ma+MID*mid))//MI
        mi_judge = (N - (MA*ma+MID*mid))%MI
        if mi>= 0 and (mi_judge == 0):
            cnt += 1
print(cnt)