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:
*RGB, N = map(int, input().split())
R = [RGB[0] * i for i in range(N+1) if RGB[0]*i <= N]
G = [RGB[1] * i for i in range(N+1) if RGB[1]*i <= N]
B = [RGB[2] * i for i in range(N+1) if RGB[2]*i <= N]

ans = [[i, j, k] for i in R for j in G for k in B if i + j + k == N]
              
print(len(ans))

Submission status: Time Limit Exceeded

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

rgb = sorted([r, g, b])
cnt = 0

for i in range(3001):
  if n < i * rgb[2]:
    break
  for j in range(3001):
    if n < i * rgb[2] + j * rgb[1]:
      break
    if (n - i * rgb[2] - j * rgb[1]) % rgb[0] == 0:
      cnt += 1
    
print(cnt)

Submission status: Time Limit Exceeded

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

count = 0
x = range(math.ceil(n/r) + 1)
y = range(math.ceil(n/g) + 1)
z = range(math.ceil(n/b) + 1)
for xx in x:
    xsum = r * xx
    if xsum > n:
       break    
    for yy in y:
        xysum = xsum + g * yy
        if xysum > n:
            break       
        for zz in z:
            sum = xysum + b * zz
            if sum == n:
                count += 1
            if sum > n:
                break

print(count)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N =list(map(int, input().split()))
# R = 13
# G = 1
# B = 4
# N = 3000
X, Y, Z = sorted([R, G, B], reverse=True)
cnt = 0
for i in range(N//X+1):
    for j in range(N+1):
        if (X*i+Y*j>N): break
        cnt += ((N-X*i-Y*j)%Z == 0)
print(cnt)

Submission status: Time Limit Exceeded

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

count = 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:
                count += 1
                break

print(count)

Submission status: Time Limit Exceeded

Solution code:
raw =  input().split()
l = [0,0,0]
l[0] = int(raw[0]) 
l[1] = int(raw[1]) 
l[2] = int(raw[2])
l.reverse()

R=l[0]
G=l[1]
B=l[2]
   
N = int(raw[3])

total = N
ans = 0
remain = 0

for r  in range (N//R +1):
    for g in range((N-r*R)//G +1):
            remain = (N - r*R - g*G ) // B
            if N == abs(remain) * B +r*R + g*G:
                  ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:

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

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

"""
3002C2=


if(C==[1,1,1]):
	print(4504501)
	exit()
if(C==[1,1,2]):
	print(2253001)
	exit()
if(C==[1,1,3]):
	exit(-1)
	print(1502501)
	exit()
if(C==[1,1,4]):
	exit(-1)
	print(1127251)
	exit()
if(C==[1,2,2]):
	exit(-1)
	print(1127251)
	exit()
"""






count=0
for i in range(N//C[2]+1):
	for j in range(N//C[1]+1):
		if(N-C[2]*i-C[1]*j>=0 and (N-C[2]*i-C[1]*j)%C[0]==0):
			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):
        k = (N - (R*i) - (G*j) ) // B
        if  (N - (R*i) - (G*j) - (B*k)) == 0 and k >= 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(3001):
    if i*r>n:
        break
    for j in range(3001):
        if i*r+j*g>n:
            break
        if (n-(r*i+g*j))%b==0 or (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())
arr = [r, g, b]
arr.sort()
ans = 0
for i in range(n // arr[2] + 1):
    if arr[2] * i > n:
        break
    for j in range(n // arr[1] + 1):
        tmp = arr[2] * i + arr[1] * j
        if tmp > n:
            break
        else:
            if tmp == n:
                ans += 1
                break
            elif n - tmp > 0 and (n - tmp) % arr[0] == 0:
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a = list(map(int, input().split()))
r = a[0]
g = a[1]
b = a[2]
n = a[3]
c = 0

for i in range(n+1):
    for j in range(n+1):
        k = (n - (r*i + g*j))//b
        if k >= 0:
            if n == r*i + g*j + b*k:
                c += 1
print(c)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = (int(i) for i in input().split())
maxr = N // R
result = 0

for i in range(maxr + 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:
            result += 1
    
print(result)

Submission status: Time Limit Exceeded

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]
f = a[0]
c = int(N / b)

count = 0

A = [N - b * i for i in range(c+1)]
C = list(map(int, A / d))

E = [A[k] - d * m for k in range(len(A)) for m in range(C[k] + 1)  ]
for g in range(len(E)):
    if E[g] % f == 0:
        count += 1
print(count)

Submission status: Time Limit Exceeded

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

i = 0
j = 0
cnt = 0

while i*R <= N:
    while i*R + j*G <= N:
        if (N - i*R - j*G) % B == 0:
            cnt += 1
        j += 1
    j = 0
    i += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
R,G,B,N=[int(x) for x in stdin.readline().rstrip().split()]
ans=0
for r in range(0,N//R+1):
    for g in range(0,(N-(R*r))//G+1):
        for b in range(0,(N-(R*r)-(G*g))//B+1):
            ball = R*r + G*g + B*b
            if 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//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]
print(len(ans))

Submission status: Time Limit Exceeded

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

# スペース区切りの整数の入力
r, g, b, n = map(int, input().split())

# 最大の数をそれぞれ求める
max_x = (int)(n / r)
max_y = (int)(n / g)
max_z = (int)(n / b)

# 答えの数
answer_num = 0

# 計算
for x in reversed(range(max_x+1)):
    for y in reversed(range(max_y+1)):
        for z in reversed(range(max_z+1)):
            calc = x*r+y*g+z*b
            if calc == n:
                answer_num += 1

# 出力
print(answer_num)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
ans = 0
r, g = 0, 0
rmax = N // R
gmax = N // G

for i in range(rmax + 1):
  for j in range(gmax + 1):
    if (N - i * R - j * G) < 0:
      break
    if (N - i * R - j * G) % B == 0:
      ans += 1
#      print(ans, i, j)
print(ans)

Submission status: Time Limit Exceeded

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

cnt = 0

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

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N =list(map(int, input().split()))
# R = 13
# G = 1
# B = 4
# N = 3000
X, Y, Z = sorted([R, G, B], reverse=True)
cnt = 0
for i in range(N+1):
    if (X*i>N): break
    for j in range(N+1):
        if (X*i+Y*j>N): break
        cnt += ((N-X*i-Y*j)%Z == 0)
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = list(map(int, input().split()))
ans = 0
r = [R*i for i in range(N//R+1)]
g = [G*i for i in range(N//G+1)]
b = [B*i for i in range(N//B+1)]

for x in r:
    for y in g:
       n = N - x - y
       if n < 0:
           break
       if n in b:
           ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from math import floor

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

cnt = 0
for r0 in range(floor(n // r)+1):
  for g0 in range(floor(n // g)+1):
    sum = r * r0 + g * g0
    if sum > n:
      continue
    if (n - sum) % b == 0:
      cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
r, g, b, n = map(int, input().split())
arr = [r, g, b]
arr.sort()
ans = 0
for i in range(n // arr[2] + 1):
    if arr[2] * i > n:
        break
    for j in range(n // arr[1] + 1):
        tmp = arr[2] * i + arr[1] * j
        if tmp > n:
            break
        else:
            if tmp == n:
                ans += 1
            elif n - tmp > 0 and (n - tmp) % arr[0] == 0:
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = (int(i) for i in input().split())
maxr = N // R
maxg = N // G
result = 0

for i in range(maxr + 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:
            result += 1
        

print(result)

Submission status: Time Limit Exceeded

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

cnt = 0

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

_i = N//li[2]

for i in range(_i+1):
    _j = (N - li[2]*i)//li[1] 
    for j in range(_j+1):
        _k = (N - li[2]*i - li[1]*j)//li[0]
        for k in range(_k, _k+1):
            if i*li[2] + j*li[1] + k*li[0] == N:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
#-------------------------------------------------------------------
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")
#-------------------------------------------------------------------

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

if R<G: R,G=G,R
if G<B: G,B=B,G
if R<G: R,G=G,R

r=g=b=0
ans=0

#p(N//R+2)
#p(N//G+2)
#X=[]
#p(r,g,b)

for r in range(N//R+2):
	if (R*r)>N: break

	for g in range(N//G+2):
		if (R*r)+(G*g)>N:
			break
			X.append("break")
		
		b = (N-(R*r)-(G*g))//B
		n = (R*r)+(G*g)+(B*b)
		if n==N:
			ans+=1
#			X.append([r,g,b])
#		p(r,g,b,n,N,ans)

print(ans)
#p(X)

Submission status: Time Limit Exceeded

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)


"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
r,g,b,n= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
s = 0
for i in range(n//r+1):
    for k in range((n-r*i)//g+1):
        left = n-(r*i+k*g)
        if left%b == 0 and left>=0:s+=1
print(s)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
R,G,B,N=[int(x) for x in stdin.readline().rstrip().split()]
ans=0
for r in range(0,N//R+1):
    for g in range(0,N-(R*r)+1):
        for b in range(0,N-(R*r)-(G*g)+1):
            ball = R*r + G*g + B*b
            if ball == N:
                ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
*RGB, N = map(int, input().split())
R = [RGB[0] * i for i in range(N+1) if RGB[0]*i <= N]
G = [RGB[1] * i for i in range(N+1) if RGB[1]*i <= N]
B = [RGB[2] * i for i in range(N+1) if RGB[2]*i <= N]
ans = 0

for i in R:
    for j in G:
        for k in B:
            if i + j + k == N:
                ans += 1
                
print(ans)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
count=0
for x in range(n+1):
    for y in range(n-x+1):
        z=(n-r*x-g*y)//b
        if 0<=z<=3000:
            if r*x+g*y+z*b==n:count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
data = list(map(int, input().split()))

R = data[0]
G = data[1]
B = data[2]
N = data[3]

# r, g, bのmax
max_index = [R, G, B].index(max([R, G, B]))

count = 0
for i in range(int(N / R)+1):
    for j in range(int(N / G)+1):
        if i * R + j * G > N:
            break
        # i,jが決まればkは回さなくていい
        if (N - (i * R + j * G)) % B == 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
a, b, c, n = map(int, input().split())
aa =[a,b,c]
aa.sort()
r = aa[2]
g = aa[1]
b = aa[0]

count = 0
for i_r in range(0,int(n/r)+1):
    if (n - r*i_r)<0:continue
    for i_g in range(0,int(n/g)+1):
        if (n - r*i_r - g*i_g)<0:continue
        if 0==((n - r*i_r - g*i_g)%b):

            count +=1

print(count)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = (int(i) for i in input().split())
maxr = N // R
maxg = N // G
maxb = N // B
result = 0

for i in range(maxr + 1):
    for j in range(maxg + 1):
        if (N - R * i - G * j) % B == 0 and (N - R * i - G * j) >= 0:
            result += 1
        

print(result)

Submission status: Time Limit Exceeded

Solution code:
r, g, b, n = map(int, input().split())
arr = [r, g, b]
arr.sort()
ans = 0
for i in range(n // arr[2] + 1):
    for j in range(n // arr[1] + 1):
        tmp = arr[2] * i + arr[1] * j
        if tmp > n:
            break
        else:
            if tmp == n:
                ans += 1
            elif n - tmp > 0 and (n - tmp) % arr[0] == 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(int(N/R)+1):
    for g in range(int(N/G)+1):
        if N-(r*R+g*G) >= 0 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

for x in range(n + 1):
    w1 = r*x
    if w1 >n:
        break
    for y in range(n + 1):
        w2 = w1 + g*y
        if w2 > n:
            break
        for z in range(n + 1):
            w3 = w2 + b * z
            if w3 > n:
                break
            if w3 == n:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
#coding: utf-8
from math import ceil
R, G, B, N = map(int, input().split())
ans = 0
for r in range(ceil(N/R) + 1):
	for g in range(ceil(N/G) + 1):
		for b in range(ceil(N/B) + 1):
			if r * R + g * G + b * B == N:
				ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
r=[0]*3
r[0],r[1],r[2],n=map(int, input().split())
ct=0
r=sorted(r)

for i in range(n//r[2]+1):
    for j in range(min(n//r[1]+1, n-r[2]*i+1)):
        if (n-(i*r[2]+j*r[1]))%r[0]==0 and 0<=(n-(i*r[2]+j*r[1]))<=n+1:
            ct+=1
print(ct)

Submission status: Time Limit Exceeded

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

lst=[r,g,b]
lst.sort()
r=lst[2]
g=lst[1]
b=lst[0]

rlim=n//r

blim=n//b

blist=[]
for i in range(blim+1):
    blist.append(i*b)


cnt=0
for i in range(rlim+1):
    glim=(n-i*r)//g
    for j in range(glim+1):
        rlim=(n-i*r-j*g)//b
        for k in range(rlim+1):
            if i*r+j*g+k*b==n:
                cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
if __name__ == "__main__":
  s = input().split(" ")
  RGB = [0 for a in range(3)]
  RGB[0] = int(s[0])
  RGB[1] = int(s[1])
  RGB[2] = int(s[2])
  N = int(s[3])
  
  SRGB = sorted(RGB,reverse=True)
  
  count = 0
  for i in range(int(N/SRGB[0])+1):
    sumR = SRGB[0] * i
    if sumR == N:
      count += 1
      break
    elif sumR > N:
      break
    else:
      for j in range(int(N/SRGB[1])+1):
        sumG = SRGB[1] * j
        if sumR + sumG == N:
          count += 1
          break
        elif sumR + sumG > N:
          break
        else:
          for k in range(int(N/SRGB[2])+1):
            sumB = SRGB[2] * k
            if sumR + sumG + sumB == N:
              count += 1
              break
            elif sumR + sumG + sumB > N:
              break
  print(count)

Submission status: Time Limit Exceeded

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

box = [R,G,B]
box.sort()

flag = False
R,G,B = box[2],box[1],box[0]
for i in range(3000//R+1):
    if flag:
        pass
    else:
        if N-i*R < 0:
            flag = True
            break
        for j in range(3000//G+1):
            if N-i*R-j*G<0:
                break
            if (N-i*R-j*G)%B == 0:
                # print(i*R+j*G)
                # print(i,j,(N-i*R-j*G)//B)
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int, input().split())
r = 0
rList = [i*R for i in range(int(N/R)+1)]
gList = [i*G for i in range(int(N/G)+1)]

for i in rList:
    for j in gList:
        if ((N-(i + j)) % B == 0 and N-(i+j) >= 0):
            r += 1

print(r)

Submission status: Time Limit Exceeded

Solution code:
*RGB, N = map(int, input().split())
R = [RGB[0] * i for i in range(N+1) if RGB[0]*i <= N]
G = [RGB[1] * i for i in range(N+1) if RGB[1]*i <= N]
B = [RGB[2] * i for i in range(N+1) if RGB[2]*i <= N]
ans = []

for i in R:
    for j in G:
        for k in B:
            if i + j + k == N:
                ans.append(((i, j, k)))
                
print(len(ans))

Submission status: Time Limit Exceeded

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

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

cnt = 0
n1 = sort_array[2]
n2 = sort_array[1]
n3 = sort_array[0]
r = n1
g = n2
b = n3

if r == 1 and g == 1 and b == 1 and n == 3000:
  cnt = 4504501
if r == 2 and g == 1 and b == 1:
  cnt = 2253001

if cnt == 0:
  for rn in range(0,n + 1):
    if (r * rn) > n:
      continue
    for gn in range(0,n + 1):
      if (r * rn + g * gn) > n:
        continue
      if (n - (r * rn + g * gn)) % b == 0:
        cnt = cnt+1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int,input().split())
count = 0
x = int(N / R)
y = int(N / G)
z = int(N / B)
rg_list = []
for r in range(x + 1):
    for g in range(y + 1):
        buf = r * R + g * G
        if buf == N :
            count += 1
        if buf < N :
            rg_list.append(buf)
rg_list.sort()
# sprint(rg_list)

rg_count_list = []
for i in range(N):
    rg_count_list.append(rg_list.count(i))

for b in range(z + 1):
    for rg in range(len(rg_count_list)):
        if rg + b*B == N :
            count += rg_count_list[rg]
        if rg + b*B > N :
            break
print(count)

Submission status: Time Limit Exceeded

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

cnt = 0

_R = N//R

for i in range(_R+1):
    _G = (N - R*i)//G 
    for j in range(_G+1):
        _B = (N - R*i - G*j)//B 
        for k in range(_B, _B+1):
            if i*R + j*G + k*B == N:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
count = 0
for a in range(0,N+1,R):
    for b in range(0,N-a+1,G):
        c = N-a-b
        if a%R == 0 and b%G == 0 and c%B == 0:
            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):
       for k in range(N+1):
           if ((R*i) + (G*j) + (B*k)) == N:
               cnt += 1
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-r*R)//G+1):
        if N-r*R-g*G < 0:
            break
        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:
# coding: utf-8
#-------------------------------------------------------------------
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")
#-------------------------------------------------------------------

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


r=g=b=0
ans=0

#p(N//R+2)
#p(N//G+2)
#X=[]
#p(r,g,b)

for r in range(N//R+2):
	if (R*r)>N: break

	for g in range(N//G+2):
		if (R*r)+(G*g)>N:
			break
			X.append("break")
		
		b = (N-(R*r)-(G*g))//B
		n = (R*r)+(G*g)+(B*b)
		if n==N:
			ans+=1
#			X.append([r,g,b])
#		p(r,g,b,n,N,ans)

print(ans)
#p(X)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
print(sum(0<=(n-r*x-g*y)/b<=3000 and (n-r*x-g*y)//b==(n-r*x-g*y)/b for x in range(n+1) for y in range(n-x+1)))

Submission status: Time Limit Exceeded

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

ans = 0

for x in range(n + 1):
    if r*x >n:
        break
    for y in range(n + 1):
        w = r * x + g * y
        if w > n:
            break
        for z in range(n + 1):
            w2 = w + b * z
            if w2 > n:
                break
            if w2 == n:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

while r * R <= N:
  g = g0
#  Nr = N
  Nr = N - r * R
#  print("Nr:", Nr, "r:", r)
  while g * G <= Nr:
#    Ng = Nr
    Ng = Nr - g * G
#    print("Ng:", Ng, "g:", g)
    if Ng % B == 0:
#      b = (Ng/B)
      ans += 1
#      print("ANS:", ans, "r:", r, "g:", g, "b:", b)
    g += 1
  r += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
raw =  input().split()
R = int(raw[0]) 
G = int(raw[1]) 
B = int(raw[2])
tmp =0 
if R < G:
    tmp = R
    R = G
    G = tmp
if G < B:
    tmp = G
    G = B
    B = tmp 
    



N = int(raw[3])

total = N
ans = 0
remain = 0

for r  in range (N//R +1):
    for g in range(N//G +1):
            remain = (N - r*R - g*G ) // B
            if N == abs(remain) * B +r*R + g*G:
                  ans+=1
            elif N < abs(remain) * B +r*R + g*G:
                  break
print(ans)

Submission status: Time Limit Exceeded

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

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

numbers = [R, G, B]
numbers.sort(reverse=True)

count = 0
for i in range(N // numbers[0] + 1):
  for j in range((N - i * numbers[0]) // numbers[1] + 1):
    for k in range((N - i * numbers[0] - j * numbers[1]) // numbers[2] + 1):
      if i * numbers[0] + j * numbers[1] + k * numbers[2] == N:
        count += 1 

print(count)

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left


def index(a, x):
    'Locate the leftmost value exactly equal to x'
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return True
    else:
        return False


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

B_list = []
for i in range(N // B + 1):
    B_list.append(N - i * B)

B_list.sort()

count = 0
for i in range(N // R + 1):
    for j in range((N - i * R) // G + 1):
        if index(B_list, i * R + j * G):
            count += 1

print(count)

Submission status: Time Limit Exceeded

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

for r in range(int(N / R) + 1):
    for g in range(int(N / G) + 1):
        x = N - r * R - g * G
        if x >= 0 and x % B == 0:
            count = count + 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
lista = []
lista.append(R)
lista.append(G)
lista.append(B)
lista.sort(reverse=True)
count = 0
wa = 0

for i in range(N//lista[0] + 1):
    for j in range(N//lista[1] + 1):
        for g in range(N//lista[2] + 1):
            if i*lista[0] + j*lista[1] + g*lista[2] > N:
                break
            elif i*lista[0] + j*lista[1] + g*lista[2] == N:
                wa += 1
            
print(wa)

Submission status: Time Limit Exceeded

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

# print(r, g, b, n)

count = 0

for i in range(3000):
  for j in range(3000):
    for k in range(3000):
      if( r * i + j * g + k * b ) == n:
        count += 1
        break
        
      if( r * i + j * g + k * b ) > n:
        break

print(count)

Submission status: Time Limit Exceeded

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

lst=[r,g,b]
lst.sort()
r=lst[2]
g=lst[1]
b=lst[0]

rlim=n//r

blim=n//b

blist=[]
for i in range(blim+1):
    blist.append(i*b)


cnt=0
for i in range(rlim+1):
    glim=(n-i*r)//g
    for j in range(glim+1):
        if (n-i*r-j*g) in blist:
            cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

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

for h in range( n // r + 1):
    i = 0
    while  h*r + i*g <= n :
        if( (n - (h*r + i*g) ) % b == 0)    :
            cnt += 1   
        i += 1
        
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
nr=n//r
nb=n//b
ans=0
lb=[b*k for k in range(nb+1)]
lst=lb.copy()

for i in lb:
  ng=(n-i)//g
  for j in range(1,ng+1):
    lst.append(i+g*j)

lst.sort()
l=len(lst)

import bisect
for i in range(nr+1):
  res=n-r*i
  idx=bisect.bisect_left(lst,res)
  if idx<l and lst[idx]==res:
    ans+=lst.count(res)
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-R*r)/G+1)):
        for b in range(int((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())

lst=[r,g,b]
lst.sort()
r=lst[2]
g=lst[1]
b=lst[0]

rlim=n//r
glim=n//g
blim=n//b

blist=[]
for i in range(blim+1):
    blist.append(i*b)


cnt=0
for i in range(rlim+1):
    #glim=(n-i*r)//g
    for j in range(glim+1):
        if (n-i*r-j*g) in blist:
            cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

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

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

count = 0

a = list()

a.append(r)
a.append(b)
a.append(g)

a.sort(reverse=True)
# print(a)

for i in range(0, n//a[0]+1):
    b = n - i*a[0]
    for j in range(0, b//a[1]+1):
        c = b - j*a[1]
        for k in range(0, c//a[2]+1):
            if c == k*a[2]:
                count += 1

# for i in range(0, n+1):
#     for j in range(0, n+1):
#         for k in range(0, n+1):
#             if r*i + g*j + b*k == n:
#                 count += 1


print(count)

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):
        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())
arr = [r, g, b]
arr.sort()
ans = 0
tmp = 0
for i in range(n // arr[2] + 1):
    for j in range(n // arr[1] + 1):
        tmp = arr[2] * i + arr[1] * j
        if tmp == n:
            ans += 1
        if n - tmp > 0 and (n - tmp) % arr[0] == 0:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
count = 0
for alpha in range(int(N/R)+1):
    for beta in range(int(N/G)+1):
        for gamma in range(int(N/B)+1):
            if (alpha * R + beta * G + gamma * B == N):
                count +=1
                
print(count)

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
cnt = 0
for r in range(R_max):
    for g in range(G_max):
        if r*R + g*G > N:
            break
        for b in range(B_max):
            if r *R + g*G + b* B > N:
                break
            elif r *R + g*G + b* B == N:
                cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

ir = N // R + 1
ig = N // G + 1
ib = N // B + 1
ans = 0
for i in range(ir):
    for j in range(ig):
        for k in range(ib):
            if i*R+j*G+k*B == N:
                ans += 1
#             print(f'{(i,j,k)} {i*R+j*G+k*B}')

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)


"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
r,g,b,n= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
s = 0
for i in range(n//r+1):
    for k in range(n//g+1):
        left = n-(r*i+k*g)
        if left%b == 0 and left>=0:s+=1
print(s)

Submission status: Time Limit Exceeded

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

c = 0
for r in range(N//R, -1, -1): 
    new1 = N - r*R
    for g in range(new1//G, -1, -1):
        new2 = new1 - g*G
        for b in range(new2//B, -1, -1):
            if b*B == new2:
                c += 1

print(c)