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

ans = 0
i = 0

while (i * R <= N):
  
  j = 0

  while (i * R + j * G <= N):

    tmp = N - (R * i) - (G * j)
    
    if tmp % B == 0 and tmp >= 0:
      ans += 1
      # print('{},{}'.format(i,j))
    j += 1
  
  i += 1

print('{0}'.format(ans))

Submission status: Time Limit Exceeded

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

def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False

ans = 0

for i in range(N + 1):
    for j in range(N + 1):
        t = (N - G * i - B * j)
        if is_integer_num(t / R) and t >= 0:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

    return r, g, b, n


def main():
    r, g, b, n = input_from_console()
    counter = 0
    r, g, b = sorted([r, g, b], reverse=True)
    # print(r,g,b)
    for i1 in reversed(range(int(n / r) + 1)):
        n1 = n - r * i1
        for i2 in reversed(range(int(n1 / g) + 1)):
            n2 = n1 - g * i2
            # print(n2, i1, i2)
            if r * i1 + g * i2 + b * (n - i1 - i2) < n2:
                continue
            for i3 in reversed(range(int(n2 / b) + 1)):
                # print(i1, i2, i3, r * i1 + g * i2 + b * i3)
                n_new = r * i1 + g * i2 + b * i3
                if r * i1 + g * i2 + b * i3 == n:
                    counter += 1
                    break
                elif n_new < n:
                    break

    print(counter)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

    return r, g, b, n


def main():
    r, g, b, n = input_from_console()
    counter = 0
    r, g, b = sorted([r, g, b], reverse=True)
    # print(r,g,b)
    for i1 in reversed(range(int(n / r) + 1)):
        n1 = n - r * i1
        for i2 in reversed(range(int(n1 / g) + 1)):
            n2 = n1 - g * i2
            # print(n2, i1, i2)
            if r * i1 + g * i2 + b * (n - i1 - i2) < n2:
                break
            for i3 in reversed(range(int(n2 / b) + 1)):
                # print(i1, i2, i3, r * i1 + g * i2 + b * i3)
                n_new = r * i1 + g * i2 + b * i3
                if r * i1 + g * i2 + b * i3 == n:
                    counter += 1
                    break
                elif n_new < n:
                    break

    print(counter)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from math import ceil

r, g, b, n = map(int, input().split())
cnt = 0
for i in range(ceil(n / r) + 1):
    for j in range(ceil(n / g) + 1):
        if i * r + j * g > n:
            break
        if i * r + j * g == n:
            cnt += 1
            continue
        else:
            tmp = n - (i * r + j * g)
            if tmp % 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 + 1):
    ball1 = N - R * r
    if ball1 >= 0:
        for g in range(N//G + 1):
            ball2 = ball1 - G * g
            if ball2 >= 0 and ball2 % B == 0:
                    cnt += 1
 
print(cnt)

Submission status: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

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

for i in range(N//lista[0] + 1):
    for j in range(N//lista[1] + 1):
        f = N - i*lista[0] - j*lista[1]
        if f % lista[2] == 0 and f >= 0:
            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):
        if r*i+g*j>n:
            break
        elif (n-r*i-g*j)%b==0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

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

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

count = 0

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

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


print(count)

Submission status: Time Limit Exceeded

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

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

a = max(r,g,b)
c = min(r,g,b)
d = r + g + b - a - c

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

            count = count + 1

print(count)

Submission status: Time Limit Exceeded

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

rgb = [R, G, B]
rgb = sorted(rgb, reverse=True)
count = 0
for i in range((N//rgb[0])+1):
    for j in range((N//rgb[1])+1):
        k = N - i * rgb[0] - j * rgb[1]
        if k >= 0:
            if k % rgb[2] == 0:
                count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
R, G, B, N = map(int ,input().split())
# R*r + G*g + B*b = N
MAX = N + 1
ok_pattern = 0
for r in range(MAX):
  for g in range(MAX):
    for b in range(MAX):
      sum = (R * r) + (G * g) + (B * b)
      if N == sum:
        # print(r, g, b)
        ok_pattern += 1
print(ok_pattern)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

num = 0
ans = 0
for r in range(N+1):
    numR = R*r
    if numR > N: continue
    for g in range(N+1):
        numG = numR + G*g
        if numG > N: continue
        b = (N-numG) / 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())
RGB = list(reversed(sorted([R,G,B])))
MAXES = [N//i for i in RGB]
answer = 0
for i in range(MAXES[0]+1):
    for j in range(MAXES[1]+1):
            if (N - (RGB[0]*i + RGB[1]*j)) % RGB[2] == 0 and N >= (RGB[0]*i + RGB[1]*j):
                # print(i,j)
                answer += 1
print(answer)

Submission status: Time Limit Exceeded

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

target = [R, G, B]
target.sort(reverse=True)
#target.sort()
# 2999 2998 3000 3000
# print(target)
resultCnt = 0
if N % target[0] == 0:
    resultCnt +=1
for a in range(N // target[0] + 1):
    if a * target[0] > N:
        break
    for b in range(N - a * target[0] + 1):
        if a * target[0] + b * target[1] > N:
            break
        if (a * target[0] + b * target[1]) == N and a * target[0] != N:
            #print(a,b)
            resultCnt += 1
            break
        if (N - (a * target[0] + b * target[1])) % target[2] == 0 and a * target[0] + b * target[1] != N:
            #print(a,b)
            #print((N - (a * target[0] + b * target[1])))
            resultCnt += 1

print(resultCnt)

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

    for g in range(0, N + 1):
        if (r * R + g * G) >= N + 1:
            break
        elif (r * R + g * G) == N:
            count += 1
            break


        elif (N - (r* R + g*G))%B == 0:
            count += 1
            continue

print(count)

Submission status: Time Limit Exceeded

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

for i in range(N+1):
    if R*i > N:
        break
    for j in range(N+1):
        if R*i + G*j > N:
            break
        for k in range(N+1):
            if R*i + G*j + B*k > N:
                break
            if R*i + G*j + B*k == N:
                count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
r = 0
list = []
while N >= R*r:
    g=0
    b=0
    while N >= R*r+G*g:
        if (N - R*r - G*g) % B == 0:
            b = (N - R*r - G*g) // B
            list.append([r,g,b])
            # print(r, g, b)
            g = g + 1
        else:
            g = g + 1 
    r = r+1
print(len(list))

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

Submission status: Time Limit Exceeded

Solution code:
r, g, b, n = map(int, input().split())
l = [r,g,b]
l.sort(reverse=True)
c = 0

for l0 in range(n//l[0],-1,-1):
    for l1 in range((n-l[0]*l0)//l[1],-1,-1):
        if (n - l[0]*l0 -l[1]* l1) < 0:
            continue
        if (n - l[0]*l0 -l[1]* l1) % l[2] == 0:
            c += 1
print(c)

Submission status: Time Limit Exceeded

Solution code:
import math

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

maxRBox = math.ceil(3000/R)
maxGBox = math.ceil(3000/G)
maxBBox = math.ceil(3000/B)

ans = 0
for ri in range(maxRBox+1):
	if N < ri*R:
		break
	for gi in range(maxGBox+1):
		if N < ri*R+gi*G:
			break
			
		if (N - (ri*R+gi*G)) % B == 0:
			bi = (N - (ri*R+gi*G)) // B
			if ri*R+gi*G+bi*B == N:
				ans +=1
				#print(ri,gi,bi,ri*R+gi*G+bi*B)
				
print(ans)

Submission status: Time Limit Exceeded

Solution code:
Rs,Gs,Bs,Ns= input().split()
R=int(Rs)
G=int(Gs)
B=int(Bs)
N=int(Ns)
lists=[R,G,B]
lists.sort(reverse=True)
ans=0
sub_ans_1=0
sub_ans_2=0
sub_ans_3=0
sub_ans_4=0


while N>sub_ans_1:
    while N>sub_ans_2:
        if (N-sub_ans_3)%lists[0]!=0:
            sub_ans_3=N+1
        while N>sub_ans_3:


            sub_ans_3=sub_ans_3+lists[0]
            if sub_ans_3==N:
                ans=ans+1
        
        sub_ans_2=sub_ans_2+lists[1]
        sub_ans_3=sub_ans_2
        if sub_ans_2==N:
            ans=ans+1

    sub_ans_1=sub_ans_1+lists[2]
    sub_ans_2=sub_ans_1
    sub_ans_3=sub_ans_1
    if sub_ans_1==N:
        ans=ans+1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n=list(map(int,input().split()))
i,j,k=0,0,0
R,G,B=0,0,0
c=0
while R<n:
    R=r*i
    while G<=n-R:
        G=g*j
        B,k=0,0
        while B<=n-R-G:
            B=b*k
            if n-R-G-B==0:
                c+=1
            k+=1
        j+=1
    i+=1
    G,j=0,0
print(c)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
[R,G,B] = sorted([R,G,B],reverse=True)
R_max = N // R+1
G_max = N//G+1
B_max = N//B+1
cnt = 0
for r in range(R_max):
    for g in range(G_max):
        if r*R + g*G > N:
            break
        rest = N - (r*R + g*G)
        if rest % B == 0:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

target = [R, G, B]
target.sort(reverse=True)
#target.sort()
# 2999 2998 3000 3000
# print(target)
resultCnt = 0
if N % target[0] == 0:
    resultCnt +=1
for a in range(N):
    if a * target[0] > N:
        break
    for b in range(N):
        if a * target[0] + b * target[1] > N:
            break
        if (a * target[0] + b * target[1]) == N and a * target[0] != N:
            #print(a,b)
            resultCnt += 1
            break
        if (N - (a * target[0] + b * target[1])) % target[2] == 0 and a * target[0] + b * target[1] != N:
            #print(a,b)
            #print((N - (a * target[0] + b * target[1])))
            resultCnt += 1

print(resultCnt)

Submission status: Time Limit Exceeded

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

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

r = math.floor(n / h[0])
count = 0
for i in range(r+1):
    g = math.floor((n - i * h[0]) / h[1])
    for j in range(g+1):
        b = math.floor((n - i * h[0] - j * h[1]) / h[2])
        for k in range(b+1):
            if i * h[0] + j * h[1] + k * h[2] == n:
                count += 1


print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
a = sorted([R,G,B],reverse=True) 
R,G,B = a[0],a[1],a[2]

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

import itertools

RC = N//R
GC = N//G
BC = N//B

RClist = [i for i in range(RC+1)]
GClist = [i for i in range(GC+1)]
BClist = [i for i in range(BC+1)]

count = 0

for a,b,c in list(itertools.product(RClist, GClist, BClist)):
    if (a*R)+(b*G)+(c*B) == N:
        count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""
"""
import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect
"""
#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


"""
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

"""
C = [0]*3
C[0], C[1], C[2], N = list(map(int, input().split()))
C.sort(reverse=True)

def main():
    cnt = 0
    CI = [N//C[0], N//C[1], N//C[2]]  
    K = [0]*(CI[2]+1)
    for k in range(CI[2]+1):
        K[k] = C[2]*k
    for i in range(CI[0]+1):
        for j in range(CI[1]+1):            
            if C[0]*i +C[1]*j > N:
                break
            if (N - (C[0]*i+C[1]*j)) in K:
                cnt+=1
    print(cnt)
                
                
                
            
            
                

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

Submission status: Time Limit Exceeded

Solution code:

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

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
RGB = list(reversed(sorted([R,G,B])))
MAXES = [N//i for i in RGB]
answer = 0
for i in range(MAXES[0]+1):
    for j in range(MAXES[1]+1):
        for k in range(MAXES[2]+1):
            if RGB[0]*i + RGB[1]*j + RGB[2]*k == N:
                answer += 1
print(answer)

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

R, G, B, N = map(int,input().split())
 
i = 0
j = 0
cnt = 0

maxi = max(R, G, B)
mini = min(R, G, B)
medi = median([R, G, B])

 
while i*maxi <= N:
    while i*maxi + j*medi <= N:
        if (N - i*maxi - j*medi) % mini == 0:
            cnt += 1
        j += 1
    j = 0
    i += 1
 
print(cnt)

Submission status: Time Limit Exceeded

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

x = N//R
y = N//G
z = N//B


for a in range(x+1):
  for b in range(y+1):
    total = a*R + b*G
    if total > N:
        break
    for c in range(z+1):
      total = a*R + b*G + c*B
      if total > N:
        break
      if total == N:
        count += 1
        break
print(count)

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:
                count += 1
            else:
                for k in range(b_num+1):
                    if r_g_remain - b * k == 0:
                        count += 1
print(count)

Submission status: Time Limit Exceeded

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

for i in range(N//rgb[2]+1):
    nokori0 = N - i * rgb[2]
    if nokori0 < 0:
        break
    if nokori0 == 0:
        ans += 1
        break
    for j in range(nokori0//rgb[1]+1):
        nokori1 = nokori0 - j * rgb[1]
        if nokori1 < 0:
            break
        if nokori1 == 0:
            ans += 1
            break
        for k in range(nokori1//rgb[0]+1):
            nokori2 = nokori1 - k * rgb[0]
            if nokori2 < 0:
                break
            if nokori2 == 0:
                ans += 1
                break
print(ans)

Submission status: Time Limit Exceeded

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

if (R<=G and R<=B):
    x = R
    if(G<B):
        y = G
        z = B
    else:
        y = B
        z = G

elif (G<=R and G<=B):
    x = G
    if(R<B):
        y = R
        z = B
    else:
        y = B
        z = R

elif (B<=G and B<=R):
    x = B
    if(G<R):
        y = G
        z = R
    else:
        y = R
        z = G


nx,ny,nz = 0,0,0

sum = N
while  (sum >= z):
    sum -= z
    nz += 1

sum = N
while (sum >= y):
    sum -= y
    ny += 1

sum = N
while (sum >= x):
    sum -= x
    nx += 1

ans=0
sum = N
for i in range(nx+1):
    for j in range(ny+1):
        for k in range(nz+1):
            sum -= i*x + j*y + k*z
            if(sum==0):
                ans += 1
            sum = N

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

RGBmax = [N // rgb for rgb in RGB]

cnt = 0
for i in range(RGBmax[0] + 1):
    if i * RGB[0] > N:
        break
    for j in range(RGBmax[1] + 1):
        if i * RGB[0] + j * RGB[1] > N:
            break
        if (i * RGB[0] + j * RGB[1] - N) % RGB[2] == 0:
            cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:

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

count = 0

for r in range(0, 3001):
    if R*r>3000:
        break
    for g in range(0, 3001):
        if R * r + G * g > 3001:
            break
        for b in range(0, 3001):
            num = R*r+G*g+B*b
            if num == N:
                count += 1
                break
            elif num > N:
                break

print(count)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(ir):
    ig = (N-i*R) // G + 1
    for j in range(ig):
        tmp = i*R + j*G
        if tmp <= N and (N - tmp) % B == 0:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

n = 0
for r in range(int(N/R)+1):
    for g in range(int(N/G)+1):
        for b in range(int(N/B)+1):
            total = r*R + g*G + b*B
            # print(r, g, b, total)
            if total == N:
                n += 1
print(n)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N = map(int,input().split())
a = sorted([R,G,B],reverse=True) 
R,G,B = a[0],a[1],a[2]

count = 0
for r in range(N//R+1):
  if r*R>N:break
  for g in range(N//G+1):
    if r*R+g*G>N: break
    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
L = sorted([R,G,B], reverse=True)
for i in range(N//L[0]+1):
    if i*L[0] > N:
        break
    for j in range(N//L[1]+1):
        if i*L[0] + j*L[1] > N:
            break
        for k in range(N//L[2]+1):
            if i*L[0] + j*L[1] + k*L[2] > N:
                break
            elif i*L[0] + j*L[1] + k*L[2] == N:
                ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
i = 0

while (i * R <= N):
  
  j = 0

  while (j * G <= N):

    tmp = N - (R * i) - (G * j)
    
    if tmp % B == 0 and tmp >= 0:
      ans += 1
      # print('{},{}'.format(i,j))
    j += 1
  
  i += 1

print('{0}'.format(ans))

Submission status: Time Limit Exceeded

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

ans = 0
X = N // R
Y = N // G
Z = N // B

for i in range(X + 1):
    for j in range(Y + 1):
        if (N - i * R - j * G) >= 0 and (N - i * R - j * G) % B == 0:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math

R, G, B, N = map(int, sys.stdin.readline().split())

count = 0
max_r = math.floor(N/R)
max_g = math.floor(N/G)
max_b = math.floor(N/B)

for i in range(max_r + 1):
    g_roop = math.floor((N - i*R)/G)
    for j in range(g_roop + 1):
        #print(N - (i * R + j * G ))
        if (i * R + j * G) > N:
            break
        if (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())
rm=n//r
gm=n//g
bm=n//b
ans=0
for i in range(rm,-1,-1):
    for j in range(gm,-1,-1):
        for k in range(bm,-1,-1):
            t=i*r+j*g+k*b
            if t<n:
                break
            elif t==n:
                ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""
import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


"""
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

"""
C = [0]*3
C[0], C[1], C[2], N = list(map(int, input().split()))
C.sort(reverse=True)

def main():
    cnt = 0
    CI = [N//C[0], N//C[1], N//C[2]]  
    K = [0]*(CI[2]+1)
    for k in range(CI[2]+1):
        K[k] = C[2]*k
    for i in range(CI[0]+1):
        for j in range(CI[1]+1):            
            if C[0]*i +C[1]*j > N:
                break
            if (N - (C[0]*i+C[1]*j)) in K:
                cnt+=1
    print(cnt)
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

count = 0
r, g, b = sorted([r, g, b])


for i in range(n // r + 1):
    total = r * i
    if total > n:
        continue
    for j in range((n - total) // g + 1):
        total = r * i + g * j
        if total > n:
            continue
        for k in range((n - total) // b + 1):
            total = r * i + g * j + b * k
            if total == n:
                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=[int(c) for c in input().split()]

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



if(C==[1,1,1]):
	print((N+2)*(N+1)//2)







count=0
for i in range(N//C[2]+1):
	for j in range(N//C[1]+1):
		if(N-C[2]*i-C[1]*j>=0 and (N-C[2]*i-C[1]*j)%C[0]==0):
			count+=1
print(count)