Problem:


Score : 200 points

Problem Statement

Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:

Red boxes, each containing R red balls

Green boxes, each containing G green balls

Blue boxes, each containing B blue balls

Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes.
How many triples of non-negative integers (r,g,b) achieve this?

Constraints

All values in input are integers.

1 \leq R,G,B,N \leq 3000

Input

Input is given from Standard Input in the following format:

R G B N

Output

Print the answer.

Sample Input 1

1 2 3 4

Sample Output 1

4

Four triples achieve the objective, as follows:

(4,0,0)

(2,1,0)

(1,0,1)

(0,2,0)

Sample Input 2

13 1 4 3000

Sample Output 2

87058



Sample input:
1 2 3 4


Sample output:
4

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b
import itertools

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

rgb_list = [r, g, b]
rgb_list.sort(reverse=True)
[x, y, z] = rgb_list

cnt = 0
for x_val in range(0, n+1, x):
    for y_val in range(0, n+1, y):
        zan = n - x_val - y_val
        if zan >=0 and zan % z == 0:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b
import itertools

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

cnt = 0
for r_val in range(0, n+1, r):
    for g_val in range(0, n+1, g):
        zan = n - r_val - g_val
        if zan >=0 and zan % 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(int(N/R) + 1):
    for j in range(int(N/G) + 1):
        tmp = int((R * i) + (G * j))
        if N >= tmp and (N - 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 r in range(0, N//R+1):    
    for g in range(0, N//G+1):
        # compute b
        b = (N - r*R - g*G) / B
        
        # judge
        if b.is_integer() and 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(0, N//R+1):
    #print('-'*10)
    #print(r)
    
    for g in range(0, N//G+1):
        #print(g)
        # compute b
        b = (N - r*R - g*G) / B
        #print(b)
        
        # judge
        if b.is_integer() and b >=0:
            count += 1
            #print('*'*10, count, '*'*10)

print(count)

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

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

#101

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

C = sorted([R,G,B])
R = C[2]
G = C[1]
B = C[0]

ans = 0

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

Submission status: Time Limit Exceeded

Solution code:
r, g, b, n = map(int, input().split())
r_num = n // r
g_num = n // g
b_num = n // b
count = 0
for i in range(r_num+1):
    r_r_remain = n - r * i
    if r_r_remain == 0:
        count += 1
    else:
        for j in range(g_num+1):
            r_g_remain = r_r_remain - g * j
            if r_g_remain >= 0:
                if r_g_remain == 0:
                    count += 1
                else:
                    if r_g_remain % b == 0:
                        count += 1
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

R, G, B, N = (int(i) for i in input().split())
#print(R, G, B, N)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=map(int,input().split())
cnt=0
for i in range(0,n+1):
    for j in range(0,n-i+1):
        bb=n-(i*r+j*g)
        s=bb+i*r+j*g
        if bb<0:
            continue
        if s==n and bb%b==0:
            cnt+=1
        if j*g>n or i*r>n or s-bb>n:break
    if i*r>n:break
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
x = [0] * 3
x[0], x[1], x[2], N = map(int, input().split())
A = [[0]*(N+1) for _ in range(4)]
A[0][0] = 1

for k in range(3):
    for i in range(N+1):
        j = 0
        while i + x[k] * j <= N:
            A[k+1][i + x[k] * j] += A[k][i]
            j += 1

print(A[3][N])

Submission status: Time Limit Exceeded

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

l.sort(reverse=True)
count=0

"""
for i in range(N):
	for j in range(N):
		k=(N-(R*i+G*j))%B
		if k==0:
			count+=1
print(count)
"""

for i in range(N+1):
	for j in range(N+1):
		if N-R*i>=0:
			a=N-R*i
			#print("a",a)
			if a-G*j>=0:
				b=a-G*j
				#print("a,b",a,b)
				if b%B==0:
					count+=1
print(count)

Submission status: Time Limit Exceeded

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

import sys
import copy

sys.setrecursionlimit(1000000)

# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~

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

ans = 0
for r in range(3001):
    for g in range(3001):
        ball = r * R + g * G
        d = N - ball
        if d >= 0 and d % B == 0:
            ans += 1
        # elif d < 0:
        #     break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = list(map(int, input().split()))
count = 0
for r in range(N//R + 1):
    for g in range(N//G + 1):
        if (N-r*R-g*G) < 0:
            break
        if (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())
count=0
wa=0
for i in range(int(N/R)+1):
    for j in range(int((N-i*R)/G)+1):
       b=(N-i*R-j*G)/B
       if b>=0 and float.is_integer(b)==True:
           count=count+1
     
print(count)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = list(map(int, input().split()))
count = 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:
            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):
    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 = list(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:
#input
a = list(map(int,input().split())) #input from array of integer like "1 2 3"
n = a[3]
a = a[:3]
range_r = n//a[0]+1
range_g = n//a[1]+1
cnt = 0
for r in range(range_r):
  for g in range(range_g):
    rg = r*a[0]+g*a[1]
    if rg > n:
      break
    if (n - rg)%a[2]==0:
      cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# Atcoder necoak answer
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_b
import itertools

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

r_list = [rn for rn in range(0, n+1, r)]
g_list = [gn for gn in range(0, n+1, g)]
b_list = [bn for bn in range(0, n+1, b)]

rgb_combis = itertools.product(r_list, g_list, b_list)

cnt = 0
for rn, gn, bn in rgb_combis:
    if (rn+gn+bn) == 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):
    if r*R>N:
        break
    else:
        for g in range(N+1):
            if ((r*R)+(g*G))>N:
                break
            else:
                if (N-(r*R)-(g*G))%B==0:
                    ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
rgbn=list(map(int,input().split()))
r=rgbn[0]
g=rgbn[1]
b=rgbn[2]
n=rgbn[3]
c=0
for i in range(n//r+1):
    for j in range((n-r*i)//g+1):
        if (n-r*i-g*j)%b==0 and n-r*i-g*j>=0:
                c+=1
print(c)

Submission status: Time Limit Exceeded

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

count = 0
for l0 in range(N//l[0]+1):
  n0 = N-l0*l[0]
  for l1 in range(n0//l[1]+1):
    l2 = (n0 - l1*l[1])/l[2]
    if l2%1.0 == 0 and l2 >= 0:
      count += 1
print(count)

Submission status: Time Limit Exceeded

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

count = 0
for l0 in range(N//l[0]+1):
  for l1 in range((N-l0*l[0])//l[1]+1):
    l2 = (N - l0*l[0] - l1*l[1])/l[2]
    if l2%1.0 == 0 and l2 >= 0:
      count += 1
print(count)

Submission status: Time Limit Exceeded

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

count = 0
for l0 in range(N//l[0]+1):
  for l1 in range(N//l[1]+1):
    l2 = (N - l0*l[0] - l1*l[1])/l[2]
    if l2%1.0 == 0 and l2 >= 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%1.0 == 0 and b >= 0:
      count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
A,B,C,N=map(int, input().split())
count=0
for x in range(N+1):
    for y in range(N-x*A+1):
        for z in range(N-y*B-x*A+1):
            if N==x*A+y*B+z*C:
                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(3000):
  for g in range(3000):
    v = R * r + G * g
    if N >= v and (N - v) % B == 0:
      cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math
r,g,b,n = map(int, input().split())
count = 0
r,g,b = sorted((r,g,b), reverse=True)
for x in range( math.ceil((n / r)) + 1):
    for y in range( math.ceil( (n - (r*x) ) / g) + 1):
        if (n - (r*x) - (y*g)) < 0:
            break
        if ((n - (r*x) - (g * y)) % b) == 0:
            count = 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(int(N/R) + 1):
    for j in range(int(N/G) + 1):
        tmp = int((R * i) + (G * j))
        if N >= tmp and (N - 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 + 1):
    for j in range(N//G + 1):
        if i*R + j*G > N:
            break
        if i*R + j*G <= N and (N - (i*R + j*G)) % B == 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int, input().split())
a = 0
for i in range(3001):
    for j in range(3001):
        if i*r + j*g >n:
            break
        else:
            x = (n-i*r - j*g)/b
            if x.is_integer() == True:
                a += 1

print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# import time
R, G, B, N = map(int, input().split())
# print(R, G, B)
i = 0
# r, g = 0, 0
# s = time.time()
for r in range(N // R + 1):
    for g in range(N // G + 1):
        if (N - r * R - g * G) >= 0:
            b = int((N - r * R - g * G) / B)
            if N - (r * R + g * G + b * B) == 0:
                # print(r, g, b)
                i += 1
print(i)
# print(time.time()-s)

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

Submission status: Time Limit Exceeded

Solution code:
#  B
import itertools

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

cnt = 0
for i in range(N//R+1):
    g_range = (N - RGB[0]*i)//RGB[1]
    for j in range((N-R*i)//G+1):
        if R*i + G*j > N:
            continue
        rem = N - R*i - G*j
        if rem % B == 0: 
            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):
        rest = N - r * R - g * G
        if rest >=0 and rest % B == 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int, input().split())
colors = [R, G, B]
colors.sort()
ans = 0

for c1 in range(N//colors[2]+1, -1, -1):
    C1 = c1*colors[2] 
    for c2 in range(N//colors[1], -1, -1):
        C2 = c2*colors[1] 
        C3 = (N-C1-C2)/colors[0]
        if C3 >= 0 and C3.is_integer():
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

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

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

l.sort(reverse = True)

cnt = 0

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

    for j in range(((n-i*l[0])//l[1])+1):
        sum = i*l[0]    #足しすぎていた。
        sum = sum + j*l[1]

        if (n - sum)%l[2] == 0:
            cnt = 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(n + 1):
    for j in range(n + 1):
        if (n - (i * r + j * g)) % b == 0 and (n - (i * r + j * g)) // b >= 0:
            ans += 1
 
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(n//r+1):
    for j in range((n-r*i)//g+1):
        if n - r*i - g*j < 0:
            continue
        if (n - r*i - g*j)%b == 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

print(count)

Submission status: Time Limit Exceeded

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

box = sorted([R,G,B],reverse=True)

count = 0
for x in range(0,N+1,box[0]):
    for y in range(0,N+1,box[1]):
        if x + y > N:
            continue
        z = (N - x - y) / box[2]
        if z >= 0 and z.is_integer():
            count += 1
print(count)

Submission status: Time Limit Exceeded

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

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

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = (int(i) for i in input().split())
ans = 0
for i in range(n//r+1):
    for j in range((n-(i*r))//g+1):
        k = (n-r*i-j*g)//b
        if sum([r*i,j*g,abs(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 i in range(n//r+1):
    """
    if n % r == 0:
        ans += 1
        continue
    """
    if n - r*i < 0:
        continue
    for j in range((n-r*i)//g+1):
        """
        if n % g == 0:
            ans += 1
            continue
        """
        if n - r*i - g*j < 0:
            continue
        if (n - r*i - g*j)%b == 0:
            ans += 1

        # print(n,i,j,n - i*r - j*g,ans)
print(ans)

Submission status: Time Limit Exceeded

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

r = 0
count = 0
r_max = N // R

while r <= r_max:

    g_max = (N-r*R)//G
    g = 0
    while N-r*R-g*G >= 0:
        b = (N-r*R-g*G)/B
        if b.is_integer() and b >= 0:
            count += 1

        g += 1
    
    r += 1

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int,input().split())
count = 0
rr = n // r
gg = n // g
for i in range(rr+1):
  for j in range(gg+1):
    if n >= i*r + j*g 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())

ans = 0
for i in range(n//r+1):
    """
    if n % r == 0:
        ans += 1
        continue
    """
    if n - r*i < 0:
        continue
    for j in range(n//g+1):
        """
        if n % g == 0:
            ans += 1
            continue
        """
        if n - r*i - g*j < 0:
            continue
        if (n - r*i - g*j)%b == 0:
            ans += 1

        # print(n,i,j,n - i*r - j*g,ans)
print(ans)

Submission status: Time Limit Exceeded

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

count = 0
for r in range(0,(N+1),R):
    for g in range(0,(N+1),G):
        if r + g > N:
            continue
        #print('r:{} g:{}'.format(r,g))
        b = (N - r - g) / B
        if b >= 0 and b.is_integer():
            count += 1
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
res=0
a=[R,G,B]
R = max(a)
G = sum(a)-R-min(a)
B= min(a)
for i in range(3000//R+1):
    for j in range(3001//G+1):
        if (N- R*i-G*j)<0:
            break
        if (N- R*i-G*j)%B==0:
            res+=1
print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

R,G,B = reversed([R,G,B])
r = 0
count = 0
r_max = N // R

while r <= r_max:
    
    g_max = (N-r*R)//G
    g = 0
    while g <= g_max:
        b = (N-r*R-g*G)/B
        if b.is_integer() and b >= 0:
            count += 1

        g += 1
    
    r += 1

print(count)

Submission status: Time Limit Exceeded

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

# R,G,B = reversed([R,G,B])
r = 0
count = 0
r_max = N // R

while r <= r_max:
    
    g_max = (N-r*R)//G
    g = 0
    while g <= g_max:
        b = (N-r*R-g*G)/B
        if b.is_integer() and b >= 0:
            count += 1

        g += 1
    
    r += 1

print(count)

Submission status: Time Limit Exceeded

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

R,G,B = reversed([R,G,B])
r = 0
count = 0
r_max = N // R
g_max = N // G

while r <= r_max:
    
    g = 0
    while g <= g_max:
        b = (N-r*R-g*G)/B
        if b.is_integer() and b >= 0:
            count += 1

        g += 1
    
    r += 1

print(count)

Submission status: Time Limit Exceeded

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

R,G,B,N=MAP()

cnt=0
for x in range(3001):
    for y in range(3001):
        z=(N-R*x-G*y)/B
        # zが0以上の整数になっていればOK
        if z>=0 and z.is_integer():
            cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
RGB = [R,G,B]
RGB.sort(reverse=True)
R = RGB[0]
G = RGB[1]
B = RGB[2]
ansR = N//R
count=0
for r in reversed(range(ansR+1)):
    amariR = N - R*r
    if amariR == 0:
        count+=1
    else:
        ansG = amariR//G
        for g in reversed(range(ansG+1)):
            amariG = amariR - G*g
            if amariG == 0:
                count+=1
            else:
                ansB = amariG//B
                for b in reversed(range(ansB+1)):
                    amariB = amariG - B*b
                    if amariB == 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(0,N+1,R):
    for g in range(0,N+1,G):
        b = (N - r - 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())
count = 0
for i in range(int(N/R) + 1):
    for j in range(int(N/G) + 1):
        temp = (N - i * R - j * G)/B
        if temp >= 0 and temp - int(temp) == 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
def main():
    r,g,b,n = map(int, input().split())
    tmp = [r,g,b]
    r,g,b = sorted(tmp, reverse=True)
    res = 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:
                    res += 1           
    print(res)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    r,g,b,n = map(int, input().split())
    res = 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:
                    res += 1           
    print(res)

if __name__ == '__main__':
    main()

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

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

Submission status: Time Limit Exceeded

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

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

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:
R,G,B,N = map(int,input().split())

r = 0
count = 0
r_max = N // R
g_max = N // G

while r <= r_max:
    
    g = 0
    while g <= g_max:
        b = (N-r*R-g*G)/B
        if b.is_integer() and b >= 0:
            count += 1

        g += 1
    
    r += 1

print(count)

Submission status: Time Limit Exceeded

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

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

print(ok)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
r, g, b, n = (int(i) for i in input().split())  
 
rmax = int(n/r)
gmax = int(n/g)
count = 0
i = 0
j = 0
k = 0

for i in range(0, rmax + 1):
  for j in range(0, gmax + 1):
    if ((n - r * i - g * j) % b == 0 and (n - r * i - g * j)>=0):
      count += 1
  
print(count)

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())
count = 0
for ri in range(0, n+1, r):
  for gi in range(0, n+1, g):
    val = (n - ri - gi) / b
    if val.is_integer() and val >= 0:
      count += 1
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

r,g,b,n = get_nums_l()

ans = 0
for ra in range(n//r + 1):
    for ga in range(n//g + 1):
        now = r * ra + g * ga
        nokori = n - now
        if nokori >= 0 and nokori % b == 0:
            ans += 1

print(ans)