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

Submission status: Time Limit Exceeded

Solution code:
#import sys

#入力受け取り
RGBN = input().split()

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

#計算用
r_num = R
#条件を満たす通り
result = 0

#Rが絡むパターンを確認
while True:
    #r_numとNが等しかったらループを抜ける
    if r_num == N:
        result = result + 1
        break
    #r_numがNを上回ったらループを抜ける
    elif r_num > N:
        break
    #r_numとg_numの組み合わせを確認
    g_num = G
    while True:
        #r_numとg_numの組み合わせが等しかったらループを抜ける
        rg_num = r_num + g_num
        if rg_num == N:
            result = result + 1
            break
        #r_numとg_numの組み合わせがNを上回ったらループを抜ける
        elif rg_num > N:
            break
        #r_numとg_numとb_numの組み合わせを確認
        b_num = B
        while True:
            #r_numとg_numとb_numの組み合わせが等しかったらループを抜ける
            rgb_num = r_num + g_num + b_num
            if rgb_num == N:
                result = result + 1
                break
            #r_numとg_numとb_numの組み合わせがNを上回ったらループを抜ける
            elif rgb_num > N:
                break
            #b_numを増やす
            b_num = b_num + B
        #g_numをG増やす
        g_num = g_num + G
    #r_numとb_numの組み合わせを確認
    b_num = B
    while True:
        #r_numとb_numの組み合わせが等しかったらループを抜ける
        rb_num = r_num + b_num
        if rb_num == N:
            result = result + 1
            break
        #r_numとb_numの組み合わせがNを上回ったらループを抜ける
        elif rb_num > N:
            break
        #b_numを増やす
        b_num = b_num + B
    #r_numを増やす
    r_num = r_num + R

#Rが絡まずGが絡むパターンを確認
g_num = G
while True:
    #g_numとNが等しかったらループを抜ける
    if g_num == N:
        result = result + 1
        break
    #g_numがNを上回ったらループを抜ける
    elif g_num > N:
        break
    #g_numとb_numの組み合わせを確認
    b_num = B
    while True:
        #g_numとb_numの組み合わせが等しかったらループを抜ける
        gb_num = g_num + b_num
        if gb_num == N:
            result = result + 1
            break
        #g_numとb_numの組み合わせがNを上回ったらループを抜ける
        elif gb_num > N:
            break
        #b_numを増やす
        b_num = b_num + B
    #g_numを増やす
    g_num = g_num + G

#Bのみが絡むパターンを確認
b_num = B
while True:
    #b_numとNが等しかったらループを抜ける
    if b_num == N:
        result = result + 1
        break
    #b_numがNを上回ったらループを抜ける
    elif b_num > N:
        break
    #b_numを増やす
    b_num = b_num + B

#resultを返却
print(result)

Submission status: Time Limit Exceeded

Solution code:
# ALC007 C

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

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

print(count)

Submission status: Time Limit Exceeded

Solution code:
# ALC007 C

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

for i in range(n+1):
    numBall = i * r
    if numBall > n:
        break
    elif numBall == n:
        count += 1
        break
    for j in range(n+1):
        numBall = i * r + j * g
        if numBall > n:
            break
        elif numBall == n:
            count += 1
            break
        else:
            if (n - numBall) % b == 0:
                count += 1

print(count)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

    print(ct)

if __name__ == "__main__":
    main()

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) :
            #print(n - (i*r) + (j*g))
            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-r*R)//G+1):
    b = (n-r*R-g*G)//B
    if r * R + g*G + b*B == n:
      cnt += 1
print(cnt)

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

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N=map(int,input().split())
r=0
g=0
b=0
count = 0
while True:
    if R*r+G*g+B*b==N:
        count +=1
    if B*b>=N:
        g+=1
        b=0
    elif G*g>=N:
        r+=1
        g=0
        b=0
    elif R*r>=N:
        print(count)
        exit()
    else:
        b+=1

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-r*R)//G+1):
    b = (n - r * R - g * G) // B
    if r * R + g * G + b * B == n:
      cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
r,g,b,n=map(int,input().split())
x,y=n//r,n//g
x,y=list(range(0,r*x+1,r)),list(range(0,g*y+1,g))
count=0
for i,j in list(itertools.product(x,y)):
  d=n-i-j
  if d<0:
    pass
  elif d==0:
    count+=1
  elif d%b==0:
    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 + 1):
    for g in range(N + 1):
        b = (N - r * R - g * G) / B
        if int(b) == b and b >= 0:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
C = sorted([r, g, b], reverse=True)
r, g, b = C[0], C[1], C[2]

for i in range(n//r+2):
    for j in range((n-r*i)//g+2):
        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//r+2):
    for j in range((n-r*i)//g+2):
        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())

cnt=0
for R in range(n//r+1):
 for G in range(n//g+1):
  num=n-R*r-G*g
  if num>=0 and num%b==0:
   cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

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

main()

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import math

point = 0

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

print(point)

Submission status: Time Limit Exceeded

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime
def run_length_encode(s):
    count = 1
    code = []
    target = s[0]
    for i in range(1, len(s)):
        if target == s[i]: count += 1
        else:
            code.append((target, count))
            target = s[i]
            count = 1
    code.append((target, count))
    return code

R,G,B,N = imn()

cnt = 0
for i in range(0,N+1):
    if i*R > N: break
    for j in range(0, N+1-i):
        if i*R + j*G > N: break
        if (N - (i*R + j*G)) % B == 0: cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime
def run_length_encode(s):
    count = 1
    code = []
    target = s[0]
    for i in range(1, len(s)):
        if target == s[i]: count += 1
        else:
            code.append((target, count))
            target = s[i]
            count = 1
    code.append((target, count))
    return code

R,G,B,N = imn()

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

Submission status: Time Limit Exceeded

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

solve()

Submission status: Time Limit Exceeded

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

solve()

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

Submission status: Time Limit Exceeded

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


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


if __name__ == '__main__':
    main()

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

Submission status: Time Limit Exceeded

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

cnt = 0
for i in range(3001):
    for j in range(3001):
        x = n - (r * i + g * j)
        if x < 0:
            continue
        if x % 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(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):
        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):
    k = n - r*i -g*j
    if k >= 0 and k%b == 0:
      #print(i, j, k)
      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):
        z = r * i + g * j
        if z <= n and (n - z) % b == 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
ans = 0
for ri in range(N//R+1):
  if ri*R > N: continue
  for gi in range(N//G+1):
    if gi*G > N: continue
    for bi in range(N//B+1):
      if bi*B > N: continue
      if ri*R+gi*G+bi*B==N:ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

for i in range(N+1):
    i *= R
    for j in range(N+1):
        j *= G
        for k in range(N+1):
            k *= 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())
rgb = [r,g,b]
rgb.sort()
x = rgb[2]
y = rgb[1]
z = rgb[0]
ans = 0

for i in range(n//x+30):
    for j in range(n//y+30):
        if (n-x*i-y*j)%z ==0:
            if (n-x*i-y*j)//z >=0:
                ans += 1
          
print(ans)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int,input().split())
rgb = [r,g,b]
rgb.sort()
x = rgb[2]
y = rgb[1]
z = rgb[0]
ans = 0

for i in range(2200):
    for j in range(2200):
        if (n-x*i-y*j)%z ==0:
            if (n-x*i-y*j)//z >=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//r)+1):
    for j in range((n//g)+1):
        rg = i * r + j * g
        rest = n - rg
        if rest < 0:
            continue
        elif rest == 0:
            count += 1
        elif rest % b == 0:
            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(N // R + 1):
    for g in range(N // G + 1):
        b = (N - R*r - G*g) / B
        if b >= 0 and b.is_integer():
            count += 1

print(count)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())  # R個の箱, G個の箱, B個の箱
ans = 0
for r in range(N+1):  # 1
    for g in range(N+1):  # 0
        b = N - (r*R + g*G)  # b = 4 - (1*1 + 0*2) = 3
        if b % B == 0 and b >= 0:
            # print(r, g, b)  # 1, 0, 1のパターンが抜けている
            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, g, b, n = map(int, input().split())
cnt = 0
for i in range(n // r + 1):
    for j in range((n - i) // g + 1):
        k = (n - i * r - j * g) / b
        if k >= 0 and k // 1 == k:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
l=[r,g,b,n]
R=n//r
G=n//g
B=n//b
count=0
l=[r,g,b]
m=min(l)
l.sort()
a=n//l[0]
b=n//l[1]
c=n//l[2]
for _a in range(a+1):
  for _b in range(b+1):
    for _c in range(c+1):
      if _a+_b+_c<=n//m:
        if l[0]*_a + l[1]*_b + l[2]*_c == n:
          count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
l=[r,g,b,n]
R=n//r
G=n//g
B=n//b
count=0
l=[r,g,b]
l.sort()
a=n//l[0]
b=n//l[1]
c=n//l[2]
for _a in range(a+1):
  for _b in range(b+1):
    for _c in range(c+1):
      if _a+_b+_c<=n:
        if l[0]*_a + l[1]*_b + l[2]*_c == n:
          count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
l=[r,g,b,n]
R=n//r
G=n//g
B=n//b
count=0
for _r in range(R+1):
  for _g in range(G+1):
    for _b in range(B+1):
      if r*_r + g*_g +b*_b == n:
        count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
import math
r,g,b,n=map(int, input().split()) 
count=0
k=[]
for i in range(n+1):
    for j in range(n+1):
        if n-(i*g+j*r)>=0:
            k.append(i*g+j*r)
        else:
            break
     
for i in range(len(k)):
    if (n-k[i])%b==0:
        count+=1
            
print(count)

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

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
tmp=0
A=0
B=0
for i in range(3001):
    if(r*i>3001):break
    for j in range(3001):
        A=r*i+g*j
        B=n-A
        if(A>3001|B<0):break
        if(((B%b)==0)&((B/b)<3001)):
            tmp+=1
print(tmp)

Submission status: Time Limit Exceeded

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

ans = 0

for i in range((N//R)+1):
    r = i
    for j in range(((N-R*r)//G)+1):
        g = j
        if (N-R*r-G*g) % 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):
    r = i
    for j in range(((N-R*r)//G)+1):
        g = j
        if (N-R*r-G*g) % B == 0:
            b = N-R*r-G*g
            if 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):
        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())
cnt=0
s=[r,g,b]
s.sort()
for i in range(n//s[2]+1):
    if i*s[2]==n:
        cnt+=1
    else:
        for j in range((n-i*s[2])//s[1]+1):
            if n-i*s[2]==s[1]*j:
                cnt+=1
            else:
                if (n-i*s[2]-j*s[1]) % s[0] ==0:
                    cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left
def index(a, x):
    i = bisect_left(a,x)
    if i != len(a) and a[i] == x:
        return True
    return False

R, G, B, N = map(int,input().split())
listB = [ i for i in range(N//B+1) ]
cnt = 0
for r in range(N//R+1):
    for g in range((N-R*r)//G+1):
        v = R*r+G*g
        if (N - v)%B == 0 and index(listB,(N - v)//B):
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left
def index(a, x):
    i = bisect_left(a,x)
    if i != len(a) and a[i] == x:
        return True
    return False
R, G, B, N = map(int,input().split())
listB = [ i for i in range(N//B+1) ]
cnt = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        v = R*r+G*g
        if (N - v)%B == 0 and index(listB,(N - v)//B):
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import sys
import os
from bisect import bisect_left
def index(a, x):
    i = bisect_left(a,x)
    if i != len(a) and a[i] == x:
        return True
    return False

R, G, B, N = map(int,input().split())
listB = [ i for i in range(N//B+1) ]
cnt = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        if index(listB,(N - R*r - G*g)/B):
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import sys
import os
from bisect import bisect_left
def index(a, x):
    i = bisect_left(a,x)
    if i != len(a) and a[i] == x:
        return True
    return False

R, G, B, N = map(int,input().split())
listB = [ i for i in range(N//B+1) ]
cnt = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        if (N - R*r - G*g)%B == 0 and  index(listB,(N - R*r - G*g)//B):
            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//G + 1):
    b = max(0, (N - r*R - g*G) // B)
    if r*R + g*G + b*B == N:
      ans += 1
    if r*R + g*G + b*B > N:
      break
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):
        if N - R*r - G*g >= 0 and (N-R*r-G*g)%B == 0:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = tuple(map(int, input().split()))
ans = 0
for i in range(N//R+1):
    for j in range(N//G+1):
        rest = (N - R * i - G * j)
        if (0 <= rest) and rest % 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+2):
    flag = False
    for j in range(n//g+2):
        tmp = n - (r*i + g*j)
        if j == 0 and tmp < 0:
            flag = True
        if tmp < 0:
            break 
        if tmp % b == 0:
            ans += 1
    if flag:
        break

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+2):
    flag = False
    for j in range(n//g+2):
        tmp = n - (r*i + g*j)
        if j == 0 and tmp < 0:
            flag = True
        if tmp < 0:
            break 
        if tmp >= 0 and tmp % b == 0:
            ans += 1
    if flag:
        break


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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int, input().split())
count = 0
c0,c1,c2 = sorted([r,g,b])
for i in range(1+n//c2):
    rest1 = n - i*c2
    if rest1 < 0:
        break
    for j in range(1+rest1//c1):
        rest = n - i*c2 - j*c1
        if rest <0:
            break
        if rest%c0 == 0 and rest >= 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int, input().split())
count = 0
c0,c1,c2 = sorted([r,g,b])
for i in range(1+n//c2):
    for j in range(1+n//c1):
        rest = n - i*c2 - j*c1
        if rest%c0 == 0 and rest >= 0:
            count += 1
print(count)