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

r = math.floor(n / R)


count = 0
for i in range(r+1):
    g = math.floor((n - i * R) / G)
    for j in range(g+1):
        b = math.floor((n - i * R - j * G) / B)
        for k in range(b+1):
            if i * R + j * G + k * B == n:
                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+1):
    for j in range(N+1):
        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:
from sys import stdin
import math
import itertools


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


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


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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

c = 0
for r in range(N + 1):
	for g in range(N + 1):
		f = (N - r * R - g * G) % B
		b = (N - r * R - g * G) // B
		if not f and (0 <= b) and (N == (r * R + g * G + b * B)): 
			#print(r, g, b)
			c += 1
print(c)

Submission status: Time Limit Exceeded

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

r, g, b = int(N // R), int(N // G), int(N // B)

ans = 0
for i in range(r + 1):
    if i * R > N:
        break
    for j in range(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())

ans = 0
for r in range(0, 3001):
    balls = R*r
    if N < balls:
        break
    for g in range(0, 3001):
        balls = R*r + G*g
        if N < balls:
            break
        left = N - balls
        if left % 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(int(n/b)+1):
    for j in range(int(n/g)+1):
        for k in range(int(n/r)+1):
            cheak = r*k + g*j + b*i
            if cheak == n:
                ans += 1
            elif cheak > n:
                break
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
        if R*i+G*j>N:
            break

    if R*i>N:
        break

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import itertools
r,g,b,n = map(int,input().split())
r_max,g_max,b_max = int(n/r),int(n/g),int(n/b)
ans = 0
for i,j,k in itertools.product(range(0,r_max+1),range(0,g_max+1),range(0,b_max+1)):
  if i*r+j*g+b*k == n:
    ans+=1  
print(ans)

Submission status: Time Limit Exceeded

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


def solve(R: int, G: int, B: int, N: int):
    cnt= 0
    for r in range(0, N+1, R):
        for g in range(0, N + 1 - r, G):
            if N - r - g < 0:
                break
            b = (N - r - g) / B
            if b % 1 == 0 and b >= 0:
                cnt += 1
            else:
                continue
    print(cnt)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(R, G, B, N)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N=[int(i) for i in input().split()]
num = 0
for i in range(N//R+1):
  for j in range(N//G+1):
#    print(i*R,j*G)
    if i*R+j*G<=N:
      if (N-i*R-j*G)%B==0:
#        print((N-i*R-j*G))
        num+=1
print(num)

Submission status: Time Limit Exceeded

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

num_r=n//r+2
num_g=n//g+2

for i in range(num_r):
    for k in range(num_g):
        if n-r*i-g*k>=0 and (n-r*i-g*k)%b==0:
            ctr+=1
print(ctr)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
MAX_INT = int(10e10)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

R,G,B,N = IL()

cnt = 0
num = N
for i in range(0,N+1,R):
    tmp = num - i
    for j in range(0,N+1,G):
        tmp2 = tmp - j
        if tmp2%B == 0 and tmp2 >= 0:
            cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

rg = {}
ri = 0
while ri <= n:
    gi = 0
    while gi <= n - ri:
        total = rg.get(ri + gi, 0)
        rg[ri + gi] = total + 1
        gi += g
    ri += r

bi = 0
result = 0

while bi <= n:
    total = rg.get(n - bi, 0)
    result += total
    bi += b

print(result)

Submission status: Time Limit Exceeded

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

i,j,k = 0,0,0

ans = 0

while True:
	temp = i * r
	j,k = 0,0
	if(temp > n):
		break
	while True:
		temp = i * r + j * g
		k = 0
		if(temp > n):
			break
		while True:
			temp = i * r + j * g + k * b
			#print(temp)
			if(temp > n): break
			if (temp == n):
				ans += 1
			k += 1
		j+= 1
	i += 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+2):
    for g in range((N-r*R)//G+2):
        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:
import math

line=input().split(" ")
n=int(line[3])
r=int(line[0])
g=int(line[1])
b=int(line[2])
nline=sorted([r,g,b])
x=int(nline[2])
y=int(nline[1])
z=int(nline[0])


answers=0
#print(x,y,z,n)


for i in range(math.ceil(n/x)+1):
    a=i
    for j in range(math.ceil(n/y)+1):
        b=j
        c=(n-a*x-b*y)/z
        if c>=0 and (n-a*x-b*y)%z==0:
            answers+=1
            #print(a,b,c)

print(answers)

Submission status: Time Limit Exceeded

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

def f(a, b):
    sho, amari = int(a/b), a%b
    return sho, amari

R_s, R_a = f(N, R)

cnt = 0

for i in range(R_s + 1):
    x = R_a + i * R # R を i 個使う
    G_s, G_a = f(x, G)
    for j in range(G_s + 1):
        y = G_a + j * G # G を j 個使う
        B_s, B_a = f(y, B)
        if B_a == 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(3001):
    if r*R > N:
        break
    for g in range(3001):
        if r*R + g*G > N:
            break
        diff = N - (r*R + g*G)
        if divmod(diff, B)[1] == 0:
            cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

count = 0


r=0
while R*r<=N:
    g=0
    while g*G+R*r<=N:
        b=(N-r*R-g*G)/B
        int_b = int(b)
        if (N-r*R-g*G)%B==0:
            b=(N-r*R-g*G)/B
            if 0<=b:
                count +=1
            else:
                break
        g += 1
    r += 1


print(count)

Submission status: Time Limit Exceeded

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

ans = 0
R = 0

while 1:
     G = 0
     if R*r>n:
          break
     while 1:
          if R*r+G*g>n:
               break
          if (n-R*r-G*g)%b == 0:
               ans += 1
          G += 1
     R += 1
     
print(ans)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
[R,G,B,N] = list(map(int,input().split()))
#[R,G,B,N] = [13,1,4,3000]
tmp = 0
for i in range(N//R+1):
    for j in range((N-i*R)//G+1):
        if (N-i*R-j*G >= 0):
            if (N-i*R-j*G)%B == 0:
                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):
    N_R = N - i * R
    for j in range(N_R // G + 1):
        N_RG = N_R - j * G
        for k in range(N_RG // B + 1):
            N_RGB = N_RG - k * B
            if N_RGB == 0:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:

a=list(map(int,input().split(" ")))
rr=a[0]
rg=a[1]
rb=a[2]
N=a[3]
count=0
for nr in range(0,N//rr+1):
    for ng in range(0,N//rg+1):
        tb=N-rr*nr-rg*ng
        if tb>=0 and tb%rb==0:
            count+=1
print(count)

Submission status: Time Limit Exceeded

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

    count = 0
    for rr in range(n//r + 1):
        for gg in range((n-rr*r)//g + 1):
            for bb in range((n-rr*r-gg*g)//b + 1):
                if (rr*r + gg*g + bb*b) == n:
                    count += 1
    print(count)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

cnt =0

# R*r + G*g + B*b == N

rm =int(N/R)
gm =int(N/G)
bm = int(N/B)

for r in range(rm+1):
    for g in range(gm+1):
        if R*r + G*g > N :
                break
        for b in range(bm+1):
            if R*r + G*g + B*b > N :
                break
            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 i in range(int(n/b)+1):
    for j in range(int(n/g)+1):
        for k in range(int(n/r)+1):
            cheak = r*k + g*j + b*i
            if cheak == n:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

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


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

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


def solve(R: int, G: int, B: int, N: int):
    cnt= 0
    for r in range(0, N+1, R):
        for g in range(0, N + 1 - r, G):
            b = (N - r - g) / B
            if b % 1 == 0 and b >= 0:
                cnt += 1
            else:
                continue
            if N - r - g < 0:
                break

    print(cnt)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(R, G, B, N)

if __name__ == '__main__':
    main()

Submission status: 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())

num_max_r = n//r
num_max_g = n//g

ans = 0
for num_r in range(num_max_r + 1):
    for num_g in range(num_max_g + 1):
        ball_rg = num_r*r + num_g*g
        ball_b = n - ball_rg
        
        if ball_b >= 0 and ball_b % b == 0:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
count = 0
R, G, B, N = map(int, input().split())
li = [R, G, B]
li = sorted(li)
ma = li[2]
mid = li[1]
mi = li[0]

for i in range(N // ma+1):
  for j in range(N // mid+1):
    rest = N - ma * i - mid * j
    if rest % mi == 0 and rest >= 0:
      count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import math
import itertools


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


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


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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

ct = 0
R, G, B, N = na()
for r in range((N // R) + 1):
    for g in range((N // G) + 1):
        if N < r * R + g * G:
            break
        elif (N - r * R - g * G) % B == 0:
            ct += 1
print(ct)

Submission status: Time Limit Exceeded

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

for i in range(n+1):
    rest = n - (i*r)
    for j in range(rest+1):
        rest = n - (i*r + j*g)
        if (rest >= 0) and (rest % b == 0):
            k = rest//b
            count += 1

print(count)

Submission status: Time Limit Exceeded

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

for i in range(n+1):
    for j in range(n+1):
        left = n - (r*i) - (g*j)
        if left >= 0 and   left % b == 0:
            counter += 1
            
print(counter)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

cnt = 0

maxr = N // R + 1
maxg = N // G + 1
maxb = N // B + 1

for r in range(0, maxr+1):
  Rr = R*r
  if Rr > N: break
  for g in range(0, maxg+1):
    RrGg = Rr + G*g
    if RrGg > N: break
    for b in range(0, maxb+1):
      p = RrGg + B*b
      if p == N:
        cnt += 1
        break
      elif p > N: break
        
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import sys, re

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7


R, G, B, N = MAP()
count = 0
for i in range(N+1):
	for j in range(int((N-i*R)//G)+1):
		# print(r, g, b)
		if R*i + G*j + B*int(max(0, (N - i*R - j*G))/B) == N:
			count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int, input().split())
cn = 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
        elif (N - R*r -G*g)%B == 0:
            cn += 1
print(cn)

Submission status: Time Limit Exceeded

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

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

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
rs = set([N-r*R for r in range(0,N+1)])

n = 0
for g in range(0,N+1):
    for b in range(0,N+1):
        if g*G+b*B in rs:
            n += 1
print(n)

Submission status: Time Limit Exceeded

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

ans = 0
R = 0

while 1:
     G = 0
     if R*r>n:
          break
     while 1:
          if R*r+G*g>n:
               break
          if (n-R*r-G*g)%b == 0:
               ans += 1
          G += 1
     R += 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 >= G*i+B*j:
            if (N-(G*i+B*j))%R == 0:
               ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

count = 0
r_max = int(N / R)+1
g_max = int(N / G)+1

for r in xrange(r_max):
    rest_val = N - R*r
    for g in xrange(g_max):
        rest_val2 = rest_val - G * g
        if rest_val2 % B == 0 and rest_val2 >= 0:
            # print "r="+str(r)+",g="+str(g)+",b="+str(rest_val2/B)
            count += 1

print count

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
r, g, b, n = map(int, input().split())

result = 0
for i in range(n+1):
    r_sp = i*r
    if r_sp > n:
        break
    for j in range(n+1):
        g_sp = j*g
        if g_sp > n:
            break

        rg = r_sp + g_sp
        if rg > n:
            break

        if (n-rg) % b == 0:
            result += 1

print(result)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map( int, input().split())
count = 0
rmax = N//R
gmax = N//G
for r in range(rmax+1):
  tmp = r * R
  for g in range(gmax+1):
    tmp2 = tmp+g*G
    if N < tmp2:
      break
    if ((N - (tmp + g * G)) % B) == 0:
      count+=1
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsm = lambda: map(str, sys.stdin.readline().split())

r, g, b, n = nm()
rn = n // r
gn = n // g
count = 0
for i in range(rn + 1):
    res = n - r * i
    if res >= 0:
        for j in range(gn + 1):
            if (res - g * j) >= 0 and (res - g * j) % b == 0:
                count += 1
            if (res - g * j) < 0:
                break
    else:
        break
print(count)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
ans = 0
i, j = 0, 0
while R*i<=N:
    while R*i+G*j<=N:
        if (N-(R*i+G*j))/B == (N-(R*i+G*j))//B:
            ans += 1
        j += 1
    else:
        j = 0
    i += 1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

r = math.floor(n / R)
g = math.floor(n / G)
b = math.floor(n / B)

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

print(count)

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(n//r[1]+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:
a, b, c, n = map(int, input().split())
count = 0
r = max(a,b,c)
g = a+b+c-max(a,b,c)-min(a,b,c) 
b = min(a,b,c)

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

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
ans=0
box=[r,g,b]
box.sort(key=lambda x:-x)
# print(box)
maxCnt=[n//box[i]+1 for i in range(3)]
# print(maxCnt)
cnt=[0,0,0]
for cnt0 in range(maxCnt[0]):
    for cnt1 in range(maxCnt[1]):
        reg=n-cnt0*box[0]-cnt1*box[1]
        if reg<0:
            break
        if reg%box[2]==0:
            ans+=1
print(ans)

Submission status: Time Limit Exceeded

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

maxr=N//R
maxg=N//G
maxb=N//B

ans=0
for i in range(maxr+1):
  for j in range(maxg+1):
    for k in range(maxb+1):
      if R*i+G*j+B*k==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):
    for b in range(N//B+1):
      if R*r + G*g + B*b == N:
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
num = 0
for i in range(N + 1):
    for j in range(N + 1):
        if N - R * i - G * j < 0:
            break
        if 0 <= N - R * i - G * j and (N - R * i - G * j) % B == 0:
            num += 1

print(num)

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):
        k = n - (i*r + j*g)
        if k < 0:
            break
        elif k >= 0 and k%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(0,(int)(n/r)+1):
    for j in range(0, (int)(n/g)+1):
        if (n-i*r-j*g)%b == 0 and (n-i*r-j*g)>=0:
            count+=1

print(count)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
count = 0
rgb = sorted([R, G, B], reverse=True)
for i in range(N+1):
    for j in range(N+1):
        tmp = N - (rgb[0] * i + rgb[1] * j)
        if 0 > tmp:
            break
        if tmp % rgb[2] == 0:
            count += 1

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(n+1):
    for j in range(n-i+1):
        rest = n - (i*r + j*g)
        if (rest >= 0) and (rest % b == 0):
            k = rest//b
            count += 1

print(count)

Submission status: Time Limit Exceeded

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

cnt = 0

maxr = N // R + 1
maxg = N // G + 1
maxb = N // B + 1

for r in range(0, maxr+1):
  if R*r > N: break
  for g in range(0, maxg+1):
    if R*r + G*g > N: break
    for b in range(0, maxb+1):
      p = R*r + G*g + B*b
      if p == N:
        cnt += 1
        break
      elif p > N: break
        
print(cnt)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

cnt = 0
for rr in range(n // r + 1):
  for gg in range(n // g + 1):
    sum = r * rr + g * gg
    rest = n - sum
    if rest < 0:
      continue
    if rest % b == 0:
      bb = (n-sum) // b
      cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(count)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(math.ceil(n/r)+1):
  for j in range(math.ceil(n/g)+1):
    if (n - r*i - g*j)%b == 0 and n - r*i - g*j >= 0:
      ans += 1
print(ans)