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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

for r in range(N//R+1):
  Rr = R*r  
  for g in range(N//G+1):
    Gg = G*g
    
    if (N - Rr - Gg) % B == 0 and 0 <= (N - Rr - Gg) and B <= NpB:
      c += 1
        
print(c)

Submission status: Wrong Answer

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

r = 0
g = 0
b = 0

for r in range(1000):
  Rr = R*r
  if Rr >= N:
    if Rr == N:
      c += 1
    break
  for g in range(1000):
    Gg = G*g
    if Rr+Gg >= N:
      if Rr+Gg == N:
        c += 1
      break
    for b in range(1000):
      Bb = B*b
      if Rr+Gg+Bb >= N:
        if Rr+Gg+Bb == N:
          c += 1
        break
        
print(c)

Submission status: Wrong Answer

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

c = 0

for r in range(R):
  if r > N:
    break
  for g in range(G):
    if r + g > N:
      break
    for b in range(B):
      if r + g + b == N:
        c += 1
      elif r + g + b > N:
        break

print(c)

Submission status: Wrong Answer

Solution code:
R,G,B,N=(int(x) for x in 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:
            cnt=cnt+1
print (cnt)

Submission status: Wrong Answer

Solution code:
R,G,B,N=(int(x) for x in input().split())
cnt=0
max=[N//R,N//G,N//B]
for r in range(1,max[0]+1):
    for g in range(1,max[1]+1):
        for b in range(1,max[2]+1):
            v=(R*r)+(G*g)+(B*b)
            if v>N:
                continue
            if v==N:
                cnt+=1
print (cnt)

Submission status: Wrong Answer

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

li = [r, g, b]
li.sort(reverse=True)

num_max_0 = n//li[0]
num_max_1 = n//li[1]
ans = 0
for num_0 in range(num_max_0 + 1):
    for num_1 in range(num_max_1 + 1):
        ball_2 = n - num_0*li[0] + num_1*li[1]
        if ball_2 >= 0 and ball_2 % li[2] == 0:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
r,g,b,n = map(int,input().split())
lis=[r,g,b]
lis.sort()
cnt=0
for i in range(n//lis[2] + 1):
  for l in range(n//lis[1]+1):
    for m in range(n//lis[0]+1):
      if i*lis[2]+l*lis[1]+i*lis[0] == n:
        cnt+=1
print(cnt)

Submission status: Wrong Answer

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

sum=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:
            sum=sum+1
        #    print(i*r,j*g,(n-(i*r)-(j*g))%b)

print(sum)

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import numpy as np

r = np.arange(0, N, R)
g = np.arange(0, N, G)
r, g = np.meshgrid(r, g)
b = N - r - g

print(np.sum(((b%B)==0) & (b>=0)))

Submission status: Wrong Answer

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

ans=[]

for r in range(int(N/R)+1):
    for g in range(int((N-r*R)/G)+1):
        for b in range(int(N-r*R-g*G)+1):
            if r*R+g*G+b*B==N:
                
                ans.append([r,g,b])
print(ans)
print(len(ans))

Submission status: Wrong Answer

Solution code:
def B(info):
    rgb = [0]*3
    *rgb, n = map(int,info.split())
    rgb.sort(reverse = True)
    count = 0
    for i in range(n//rgb[0]+1):
        new_n = n - i*rgb[0]
        if new_n < rgb[2] and new_n != 0:
            continue
        for j in range(new_n//rgb[1]+1):
            print(i,j)
            if (new_n-rgb[1]*j)%rgb[2] == 0:
                count += 1

    return count

    
if __name__ == '__main__':
    print(B(input()))

Submission status: Wrong Answer

Solution code:
def B(info):
    rgb = [0]*3
    *rgb, n = map(int,info.split())
    rgb.sort(reverse = True)
    count = 0
    for i in range(n//rgb[0]+1):
        new_n = n - i*rgb[0]
        if new_n < rgb[2]:
            continue
        for j in range(new_n//rgb[1]+1):
            if (new_n-rgb[1]*j)%rgb[2] == 0:
                count += 1

    return count

    
if __name__ == '__main__':
    print(B(input()))

Submission status: Wrong Answer

Solution code:
def B(info):
    rgb = [0]*3
    *rgb, n = map(int,info.split())
    rgb.sort(reverse = True)
    count = 0
    for i in range(n//rgb[0]+1):
        new_n = n - i*rgb[0]
        if new_n//rgb[1] < 1 and new_n//rgb[2] < 1:
            continue
        for j in range(new_n//rgb[1]+1):
            if (new_n-rgb[1]*j)%rgb[2] == 0:
                count += 1

    return count

    
if __name__ == '__main__':
    print(B(input()))

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))

count = 0
check = 0
check2 = 0
check3 = 0
i = 0
j = 0
k = 0

while i <= a[3]/a[0]:
    #check = check + a[0]
    if(check == a[3]):
        #print("a"+"i="+str(i)+"j="+str(j)+"k="+str(k))
        count += 1
    elif(check > a[3]):
        break
    check2 = check
    if(check != a[3]):
        while j <= a[3]/a[1]:
            #check2 = check2 + a[1]
            if(check2 == a[3]):
                #print("b"+"i="+str(i)+"j="+str(j)+"k="+str(k)+str(check2))
                count += 1
                j = 0
            elif(check2 > a[3]):
                j = 0
                break
            check3 = check2
            if(check2 != a[3]):
                while k <= a[3]/a[2]:
                    #print(k)
                    #check2 = check2 + a[1]
                    if(check3 == a[3]):
                        #print("c"+"i="+str(i)+"j="+str(j)+"k="+str(k)+str(check3))
                        count += 1
                        k = 0
                    elif(check3 > a[3]):
                        k = 0
                        break
                    k += 1
                    check3 = check3+ a[2]
                    if(k > a[3]/a[2]):
                        k = 0
                        break
            j += 1
            check2 = check2+ a[1]
        check = check + a[0]
    i += 1
                
print(count)

Submission status: Wrong Answer

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):
    for y_val in range(0, ((n-x_val)//z)+1, y):
        zan = n - x_val - y_val
        if zan >=0 and zan % z == 0:
            cnt += 1
print(cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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-b):
		r=(-G*g-B*b+N)/R
		if (r==int(r))&(r>=0): count+=1
print(count)

Submission status: Wrong Answer

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): count+=1
		g+=1
	b+=1
print(count)

Submission status: Wrong Answer

Solution code:
R, G, B, N = map(int, input().split())
l = sorted([R, G, B])[::-1]
print(-3 % 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]
    if l2%l[2] == 0 and l2 >= 0:
      count += 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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):
    b=(N-x*A-y*B)/C
    if b>=0:
      count+=1
                
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
r,g,b,n = map(int, input().split(" "))
l = sorted([r,g,b])
count=0
for i in range(3000):
    for j in range(3000):
        x = l[2]*i
        y = l[1]*j
        if (n-x-y) >= 0 and (n-x-y)%l[0] == 0:
            count = count + 1
print(count)

Submission status: Wrong Answer

Solution code:
r,g,b,n = map(int, input().split(" "))
l = sorted([r,g,b])
count=0
for i in range(n):
    for j in range(n):
        x = l[2]*i
        y = l[1]*j
        if (n-x-y) >= 0 and (n-x-y)%l[0] == 0:
            count = count + 1
print(count)

Submission status: Wrong Answer

Solution code:
r,g,b,n = map(int, input().split(" "))
l = sorted([r,g,b])
count=0
for i in range(n):
    for j in range(n):
        x = l[2]*i
        y = l[1]*j
        if (n-x-y)%l[0] == 0:
            count = count + 1
print(count)

Submission status: Wrong Answer

Solution code:
r,g,b,n = map(int, input().split(" "))
l = sorted([r,g,b])
count=0
for i in range(n):
    for j in range(n):
        x = l[2]*i
        y = l[1]*j
        if (n-x-y) < 0:
            break
        if (n-x-y)%l[0] == 0:
            count = count + 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
r,g,b,n = map(int, input().split(" "))
l = sorted([r,g,b])
count=0
for i in range(n):
    for j in range(n):
        x = l[2]*i
        y = l[1]*j
        if (n - (x + y)) < 0:
            break
        if (n-(x+y))%l[0] == 0:
            count = count + 1
print(count)

Submission status: Wrong Answer

Solution code:
r,g,b,n = map(int, input().split(" "))
l = sorted([r,g,b])
count=0
for i in range(n):
    for j in range(n):
        x = l[2]*i
        y = l[1]*j
        if x + y > n:
            break
        if (n-(x+y))%l[0] == 0:
            count = count + 1
print(count)

Submission status: Wrong Answer

Solution code:
r,g,b,n = map(int, input().split(" "))
l = sorted([r,g,b])
count=0
for i in range(n):
    for j in range(n):
        x = l[2]*i
        y = l[1]*j
        if x + y > n:
            break
        if (x+y)%l[0] == 0:
            count = count + 1
print(count)

Submission status: Wrong Answer

Solution code:
[r,g,b,n] = list(map(int, input().split(" ")))
l = [r,g,b]
l.sort()
count=0
for i in range(n):
    for j in range(n):
        x = l[2]*i
        y = l[1]*j
        if x + y > n:
            break
        if (x+y)%l[0] == 0:
            count = count + 1
print(count)

Submission status: Wrong Answer

Solution code:
[r,g,b,n] = list(map(int, input().split(" ")))
l = [r,g,b]
l.sort()
count=0
for i in range(n):
    x = l[2]*i
    if x > n:
        break
    for j in range(n):
        y = l[1]*j
        if x + y > n:
            break
        if (x+y)%l[0] == 0:
            count = count + 1
print(count)

Submission status: Wrong Answer

Solution code:
[r,g,b,n] = list(map(int, input().split(" ")))
l = [r,g,b]
l.sort()
count=0
for i in range(n):
    x = l[2]*i
    if x > n:
        break
    for j in range(n):
        y = l[1]*j
        if x + y > n:
            continue
        if (x+y)%l[0] == 0:
            count = count + 1
print(count)

Submission status: Wrong Answer

Solution code:
[r,g,b,n] = list(map(int, input().split(" ")))
l = [r,g,b]
l.sort()
count=0
for i in range(n):
    x = l[2]*i
    if x > n:
        break
    for j in range(n):
        y = l[1]*j
        if x + y > n:
            break
        if x+y%l[0] == 0:
            count = count + 1
print(count)

Submission status: Wrong Answer

Solution code:
[r,g,b,n] = list(map(int, input().split(" ")))
l = [r,g,b]
l.sort()
count=0
for i in range(n):
    x = l[2]*i
    if x > n:
        break
    for j in range(n):
        y = l[1]*j
        if x + y > n:
            break
        if (l[2]*i + l[1]*j) % l[0] == 0:
            count = count + 1
print(count)

Submission status: Wrong Answer

Solution code:
r,g,b,n = map(int,input().split())
a = [0]*(n+1)
a[0] = 1
for j in range(n+1-r):
    a[j+r]=1
for j in range(n+1-b):
    a[j+b]+=a[j]
for j in range(n+1-g):
    a[j+g]+=a[j]
    #print(a)
print(a[n])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = list(map(int, input().split()))
n.sort()
rmax = int(n[3] / n[2])
ans = 0
k = n[3] % n[0]

for i in range(0, rmax+1):
  sum = i * n[2]
  while sum <= n[3]:
    if sum % n[0] == k:
      ans += 1
    sum += n[1]

print(ans)

Submission status: Wrong Answer

Solution code:
# import time

R, G, B, N = map(int, input().split())
# print(R, G, B)
RGB = [R, G, B]
RGB.sort(reverse=False)
RGB[1], RGB[2] = RGB[2], RGB[1]
# print(RGB)
i = 0
# r, g = 0, 0
# s = time.time()
for r in range(N // RGB[0] + 1):
    for g in range(N // RGB[1] + 1):
        if (N - r * RGB[0] - g * RGB[1]) >= 0:
            b = int((N - r * RGB[0] - g * RGB[1]) / B)
            if N - (r * RGB[0] + g * RGB[1] + b * RGB[2]) == 0:
                # print(r, g, b)
                i += 1
print(i)
# print(time.time() - s)

Submission status: Wrong Answer

Solution code:
n = list(map(int, input().split()))

rmax = int(n[3] / n[0])
ans = 0

for i in range(0, rmax+1):
  sum = i * n[0]
  while sum <= n[3]:
    if sum % n[2] == 0:
      ans += 1
    sum += n[1]

print(ans)

Submission status: Wrong Answer

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

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


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

Submission status: Wrong Answer

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:
             cnt += 1
print(cnt)

Submission status: Wrong Answer

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)) == n:
            ans += 1
print(ans)

Submission status: Wrong Answer

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) == n:
            ans += 1
print(ans)

Submission status: Wrong Answer

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

print(res)

Submission status: Wrong Answer

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
sum = 0
for i in range(n//l[0]+1):
    sum = i*l[0]

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

        if ((n-sum)%l[2]) == 0:
            cnt = cnt + 1

print(cnt)

Submission status: Wrong Answer

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
sum = 0
for i in range(n//l[0]+1):
    sum = i*l[0]

    for j in range((n-sum)//l[1]+1):
        sum = sum + l[1]

        if (n - sum)%l[2] == 0:
            cnt = cnt +1

print(cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,n=map(int,input().split())
ans=0
for x in range(0,n+1,a):
  for y in range(x,n+1,b):
    if y%c==0:
      ans+=1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,n=map(int,input().split())
ans=0
for x in range((n+1)//a):
  for y in range((n+1-a*x)//b):
    z=n-a*x-b*y
    if z>=0 and z%c==0:
      ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
R,G,B,N=map(int,input().split())
q=[R,G,B]
s=[0,0,3001]
cnt =0
 
# R*r + G*g + B*b == N
for j in range(0,3):
    if q[j]>s[0]:
        s[0]=q[j]
 
for j in range(0,3):
    if q[j]<s[2]:
        s[2]=q[j]
        
for j in range(0,3):
    if q[j]!=s[0] and q[j]!=s[2]:
        s[1]=q[j]
        break
rm =int(N/s[0]) if s[0]>0 else 0
gm =int(N/s[1]) if s[1]>0 else 0
bm = int(N/s[2]) if s[2]>0 else 0
 
for r in range(rm+1):
    for g in range(gm+1):
        if s[0]*r + s[1]*g > N :
            break
        for b in range(bm+1):
 
            if s[0]*r + s[1]*g + s[2]*b == N :
                cnt +=1
            elif s[0]*r + s[1]*g + s[2]*b > N :
                break
                
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
r,b,g,n = map(int, input().split())
 
if r < b:
    hoge = r
    r = b
    b = hoge
 
if b < g:
    hoge = b
    b = g
    g = hoge
 
if r < b:
    hoge = r
    r = b
    b = hoge
 
kekka = 0
i = 0
while i*r <= n:
    j = 0
    while i*r+j*b <= n:
        if (n-i*r+j*b)%g == 0:
            kekka += 1
        j += 1
    i += 1
print(kekka)

Submission status: Wrong Answer

Solution code:
# r,g,b,n = map(int, input().split())
r=13
g=1
b=4
n=3000
count=0
rmax=n//r
# print('rmax:' + str(rmax))

for i in range(rmax+1):
#     print('i:' + str(i))
    n_r=n-r*i
#     print('n_r:' + str(n_r))
    gmax=n_r//g
#     print('gmax:' + str(gmax))

    for j in range(gmax+1):
#         print('j:' + str(j))
        n_rg=n_r-g*j
#         print(i,j,n_rg)
#         print('n_rg:' + str(n_rg) + '/3')
        
        if n_rg%b==0:
            count+=1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
R,G,B,N=map(int,input().split())
q=[R,G,B]
s=[0,0,3001]
cnt =0

# R*r + G*g + B*b == N
for j in range(0,3):
    if q[j]>s[0]:
        s[0]=q[j]

for j in range(0,3):
    if q[j]<s[2]:
        s[2]=q[j]
        
for j in range(0,3):
    if q[j]!=s[0] and q[j]!=s[2]:
        s[1]=q[j]
        break
rm =int(N/s[0]) if s[0]>0 else 0
gm =int(N/s[1]) if s[1]>0 else 0
bm = int(N/s[2]) if s[2]>0 else 0
 
for r in range(rm+1):
    for g in range(gm+1):
        if s[0]*r + s[1]*g > N :
            break
        for b in range(bm+1):

            if s[0]*r + s[1]*g + s[2]*b == N :
                cnt +=1
            elif s[0]*r + s[1]*g + s[2]*b > N :
                break
                
print(cnt)

Submission status: Wrong Answer

Solution code:
R,G,B,N=(int(x) for x in input().split())
count=0
R1=N//R
R2=N//G
R3=N//B
for r in range(R1+1):
    n=N
    n=n-r*R
    if n==0:
        count=count+1
    if n>0:
        for g in range(n+1):
            n=N-r*R
            n=n-g*G
            if n==0:
                count=count+1
            if n>0:
                n=N-r*R-g*G
                if n//B==0:
                    count=count+1

print(count)

Submission status: Wrong Answer

Solution code:
r, g, b, n = map(int, input().split())
s = [n - r*i - g*j for i in range(n + 1) for j in range(n + 1)]
print(s.count(0))

Submission status: Wrong Answer

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

min_num = min(r,g,b)
max_num = max(r,g,b)
middle_num = r+g+b-min_num-max_num

a = int(n / max_num)

count = 0
for i in range(0, a+1):
    x = n - max_num * i
    if x % max_num == 0:
        count += 1
    else:
        b = int(x / middle_num)
        for j in range(0,b+1):
            y = x - middle_num * j
            if y % middle_num == 0:
                count += 1
            else:
                c = int(y / min_num)
                if c % min_num == 0:
                    count += 1
    x=0
    y=0
    z=0


print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#B
import numpy as np
import math
import re

a,b,c,n = list(map(int,re.split(" ",input())))
N = n
s = []
s.append(a)
s.append(b)
s.append(c)
s.sort()
a,b,c = s
#print(a,b,c)
ans = 0
for i in range(int(N/c)+1):
    for j in range(int((N-i*c)/b)+1):
            if (N - i*c  - j*b)%a == 0:
                ans += 1
            else:
                break;
print(ans)

Submission status: Wrong Answer

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

colors = [R,G,B]

dp = [[0 for _ in range(N)] for _ in range(3)]

for i in range(N):
  if i % R == 0:
    dp[0][i] = 1

for i in range(3):
  dp[i][0] = 1

for i in range(1, 3):
  for j in range(1, N):
    use = dp[i][j - colors[i]] if j - colors[i] >= 0 else 0
    notuse = dp[i-1][j]
    dp[i][j] = use + notuse
        
print(max(max(dp)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力

import math

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

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

R = sort_list[0]
G = sort_list[1]
B = sort_list[2]

max_r = math.floor(N / R)
count = 0

if max_r == 1:
    count = math.factorial(N + 1)

else:
    for r in range(max_r + 1):
    
        max_g = math.floor((N - R * r) / G)    

        if max_g == 1:
            count += math.factorial(N - R * r + 1)
            
        else:
            for g in range(max_g + 1):
        
                b = math.floor((N - R * r - G * g) / B)        

                if (r * R + g * G + b * B) == N:
                    count += 1
                
# 出力
print("{}".format(count))

Submission status: Wrong Answer

Solution code:
R, G, B, N = map(int,input().split())
R, G, B = sorted([R, G, B])
cnt = 0
for i in range(N+1):
  for j in range(N+1):
    k = N - B*i - G*j
    if k >= 0:
      if B*i + G*j + R*k == N:
        cnt += 1
    else:
      break
print(cnt)

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

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  = C[2]*list(range(CI[2]+1))
    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: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

R, G, B, N = map(int,input().split())
R, G, B = sorted([R, G, B])
cnt = 0
for i in range(N+1):
  for j in range(N+1):
    k = N - B*i - G*j
    if k >= 0:
      if B*i + G*j + R*k == N:
        cnt += 1
    else:
      break
print(cnt)