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: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
ans=0
X = max(R,G,B)
Z = min(R,G,B)
Y = R+G+B-X-Z

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

Submission status: Time Limit Exceeded

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
R,G,B,N = map(int,input().split())

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

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
p=0
i,j=0,0
while j < n+1:
    k=i*r+j*g
    if (n-k)%b==0 and k <= n:
        #print(i,j,n-k)
        p+=1
    i+=1
    if i>n:
        i=0
        j+=1
print(p)

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

      
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

rgb = []
for r in range(N//R + 1):
    for g in range((N - r*R)//G + 1):
        tmp = N-r*R-g*G
        if tmp%B == 0:
            rgb.append((r,g,tmp//B))

print(len(set(rgb)))

Submission status: Time Limit Exceeded

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

rgb = []
for r in range(N//R + 1):
    for g in range((N - r*R)//G + 1):
        tmp = N-r*R-g*G
        if tmp >= 0 and tmp%B == 0:
            rgb.append((r,g,tmp//B))

print(len(set(rgb)))

Submission status: Time Limit Exceeded

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

rgb = []
s = set([x*B for x in range(N) if x*B <= N])
for r in range(N//R + 1):
    for g in range((N - r*R)//G + 1):
        if N-r*R-g*G in s:
            rgb.append((r,g,(N-r*R-g*G)//B))

print(len(set(rgb)))

Submission status: Time Limit Exceeded

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

rgb = []
s = set([x*B for x in range(N) if x*B <= N])
for r in range(N//R + 1):
    for g in range(N//G + 1):
        if N-r*R-g*G in s:
            rgb.append((r,g,(N-r*R-g*G)//B))

print(len(set(rgb)))

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

Submission status: Time Limit Exceeded

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

rgb = []
for r in range(N+1):
    for g in range(N+1):
        if N-r*R-g*G >= 0 and (N-r*R-g*G)%B == 0:
            rgb.append((r,g,(N-r*R-g*G)//B))

print(len(set(rgb)))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
r , g , b , n = map(int,input().split())
ans = 0
R = -(-n//r)
G = -(-n//g)
for i in range(R+1):
    for j in range(G+1):
        su = n-r*i-g*j
        if n-r*i-g*j < 0:
            break
        else:
            if (su/b).is_integer():
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
r , g , b , n = map(int,input().split())
ans = 0
R = -(-n//r)
G = -(-n//g)
for i in range(R+1):
    for j in range(G+1):
        
        if n-r*i-g*j < 0:
            break
        else:
            if ((n-r*i-g*j)/b).is_integer():
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
r , g , b , n = map(int,input().split())
ans = 0
R = -(-n//r)
G = -(-n//g)
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)/b).is_integer():
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
r , g , b , n = map(int,input().split())
ans = 0
R = -(-n//r)
G = -(-n//g)
for i in range(R+1):
    for j in range(G+1):
        if n-(r*i+g*j)>=0 and (n - (r*i+g*j)) % 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-(r*i+g*j)>=0 and (n - (r*i+g*j)) % b ==0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int,input().split())
count = 0
for i in range(n+1):
    for j in range(n+1):
        all_sum = n
        all_sum  -= i*r
        all_sum  -= j*g
        if all_sum < 0:
            continue
        if all_sum %b == 0 and i+j+(all_sum//b) != 0:
            count += 1
            #print(i,j,all_sum,b)
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

x=0
while x*r<=n:
    y=0
    while y*g<=n-x*r:
        n0=n-x*r-y*g
        if n0 % b == 0:
            ans+=1
        y+=1
    x+=1
print(ans)

Submission status: Time Limit Exceeded

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

ans = 0

for x in range(n//r + 1):
    for y in range(n // g + 1):
        if (n - (r * x + g * y)) % b == 0 and (n - (r*x + g*y)) >= 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    R,G,B,N=map(int,input().split())
    cnt=0
    for r in range(N+1):
        for g in range(N+1):
            val=(N-R*r-G*g)/B
            if val==int(val) and val>=0:
                cnt+=1
    print(cnt)

resolve()

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

r, g, b, n = map(int, stdin.readline().rstrip().split())
count = 0
for i in range(n + 1):
    for j in range(n + 1):
        if i * r + j * g <= n:
            if (n - (i * r + j * g)) % b == 0:
                # print(i, j, int((n - (i * r + j * i)) / b))
                count += 1
print(count)

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

Submission status: Time Limit Exceeded

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

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

ans = 0

for i in range(N + 1):
    for j in range(N + 1):
        k = (N - i * R - j * G) / B
        if k.is_integer() and k >= 0:
            # print(i, j, k)
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

r,g,b,n=mii()

rr=n//r +1
gg=n//g +1
bb=n//b +1
ans=0
for i in range(rr):
    for j in range(gg):
        for k in range(bb):
            if i*r+j*g+k*b==n:
                ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
R,G,B,N = inputlist()
ans = 0
for r in range(N//R + 1):
    for g in range(N//G + 1):
        b = N -(r*R+g*G)
        if b < 0:
            continue
        if b % B == 0:
            ans +=1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

for r in range(n_iter_r):
    for g in range(n_iter_g):
        if N - R*r - G*g < 0:
            break
        else:
            if (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
n_iter_r = N//R + 1
n_iter_g = N//G + 1

for r in range(n_iter_r):
    for g in range(n_iter_g):
        if N - R*r - G*g < 0:
            break
        else:
            if (N - R*r - G*g)%B==0:
                if (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
n_iter_r = N//R + 1
n_iter_g = N//G + 1

for r in range(n_iter_r):
    for g in range(n_iter_g):
        if N - R*r - G*g < 0:
            continue
        else:
            if (N - R*r - G*g)%B==0:
                if (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

n_iter_r = int(N/R)+1
n_iter_g = int(N/G)+1

for r in range(n_iter_r):
    for g in range(n_iter_g):
        if (N - R*r - G*g)%B==0:
            if (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 r in range(N//R+1):
  for g in range(N//G+1):
    if R*r+G*g>N: continue
    if (N-R*r-G*g)%B!=0: continue
    ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def input_list():
  return list(map(int, input().split()))

def main():
  r, g, b, n = input_list()
  ans = 0
  for x in range(n//r+1):
    for y in range(n//g+1):
      rr = r*x
      gg = g*y
      if rr + gg > n:
        continue
      bb = (n - rr - gg)
      if bb % b != 0:
        continue
      ans += 1
  print(ans)

main()

Submission status: Time Limit Exceeded

Solution code:
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  r, g, b, n = input_list()
  ans = 0
  for x in range(n//r+1):
    for y in range(n//g+1):
      rr = r*x
      gg = g*y
      if rr + gg > n:
        continue
      bb = (n - rr - gg)
      if bb % b != 0:
        continue
      ans += 1
  print(ans)
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Submission status: Time Limit Exceeded

Solution code:
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  r, g, b, n = input_list()
  min_num = min([r,g,b])
  ans = 0
  for x in range(n//r+1):
    for y in range(n//g+1):
      rr = r*x
      gg = g*y
      if rr + gg > n:
        continue
      bb = (n - rr - gg)
      if bb % b != 0:
        continue
      ans += 1
  print(ans)
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

print(cnt)

Submission status: Time Limit Exceeded

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

RL=(N+R-1)//R

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

print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
L=[r,g,b]
L.sort(reverse=True)
cnt=0
for i in range(n//L[0]+1):
    for j in range(n//L[1]+1):
        if (n-i*L[0]-j*L[1])%L[2]==0 and n-i*L[0]-j*L[1]>=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//r+1):
    for j in range(n//g+1):
        if (n-i*r-j*g)%b==0 and n-i*r-j*g>=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 n-i*r-j*g>=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//r + 1):
    for j in range(n//g + 1):
        k = (n - i*r - j*g)
        if k >= 0 and k % b == 0:
            cnt += 1
            # print(i, j, k)

print(cnt)

Submission status: Time Limit Exceeded

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

print(cnt)

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

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
d = {i:0 for i in range(N+1)}

for i in range((N//G)+1):
    for j in range((N//B)+1):
        if i*G+j*B<=N:
            d[i*G+j*B] += 1

ans = 0
for i in range((N//R)+1):
    ans += d[N-(R*i)]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict

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

for i in range((N//G)+1):
    for j in range((N//B)+1):
        d[i*G+j*B] += 1

ans = 0
for i in range((N//R)+1):
    ans += d[N-(R*i)]
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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