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:
import math
r, g, b, n=map(int, input().split())
r_number=math.ceil(n/r)
g_number=math.ceil(n/g)
b_number=math.ceil(n/b)
count=0
list=[]
for i in range(b_number):
    target=n-b*i
    for j in range(g_number):
        target=target-g*j
        if target>0 and target%r==0 and (int(target/r), j, i) not in list:
            count=count+1
            list.append((int(target/r), j, i))
for i in range(g_number):
    target=n-g*i
    for j in range(r_number):
        target=target-r*j
        if target>0 and target%b==0 and (j, i, int(target/b)) not in list:
            count=count+1
            list.append((j, i, int(target/b)))
for i in range(r_number):
    target=n-r*i
    for j in range(b_number):
        target=target-b*j
        if target>0 and target%g==0 and (i, int(target/g), j) not in list:
            count=count+1
            list.append((i, int(target/g), j))


print(count)

Submission status: Wrong Answer

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

for r in range(1, N + 1):
    if r * R >= N + 1:
        continue
    elif r * R == N:
        count += 1
        continue

    for g in range(1, 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
            break

print(count)

Submission status: Wrong Answer

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


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


            sub_ans_3=sub_ans_3+R
            if sub_ans_3==N:
                ans=ans+1
        
        sub_ans_2=sub_ans_2+G
        sub_ans_3=sub_ans_2
        if sub_ans_2==N:
            ans=ans+1

    sub_ans_1=sub_ans_1+B
    sub_ans_2=sub_ans_1
    sub_ans_3=sub_ans_1
    if sub_ans_1==N:
        ans=ans+1

print(ans)

Submission status: Wrong Answer

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

A = max(a, b, c)
C = min(a, b, c)
B = a+b+c-A-C


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


cnt = 0
for _a in range(int(N/A)+1):
    k = N - A * _a
    for _b in range(int(k / B)+1):
        K = k - B * _b
        if K % C == 0:
            #print(k, K, _a, _b)
            cnt += 1
            cnt += (K // lcm(B, C)) * C
            break

print(cnt)

Submission status: Wrong Answer

Solution code:
R,G,B,N = [int(i) for i in input().split()]
num = 0
 
box = sorted([R,G,B], key=lambda x:-x)
nums = [N//b for b in box]
for i in range(nums[0]+1):
    temp = N-box[1]*((N-(nums[0]-i)*box[0])//box[1])
    if temp % box[2] != 0:
        continue
    for j in range(nums[1]+1):
        resj = (nums[0]-i)*box[0] + (nums[1]-j)*box[1]
        if resj + nums[2]*box[2] < N:
            break
        if resj > N:
            continue
        if (N-resj)%box[2]!=0:
            continue
        num += 1
print(num)

Submission status: Wrong Answer

Solution code:
R,G,B,N = [int(i) for i in input().split()]
num = 0
 
box = sorted([R,G,B], key=lambda x:-x)
nums = [N//b for b in box]
for i in range(nums[0]+1):
    temp = N-box[1]*((N-(nums[0]-i)*box[0])//box[1])
    if temp % box[2] != 0:
        break
    for j in range(nums[1]+1):
        resj = (nums[0]-i)*box[0] + (nums[1]-j)*box[1]
        if resj + nums[2]*box[2] < N:
            break
        if resj > N:
            continue
        if (N-resj)%box[2]!=0:
            continue
        num += 1
print(num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Solution code:
r, g, b, n = map(int, input().split())
l = [r,g,b]
l.sort(reverse=True)
print(l)
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:
            print('l0:'+str(l0)+' l1:'+str(l1))
            c += 1
print(c)

Submission status: Wrong Answer

Solution code:
# coding:utf-8

import math
import re

def median(lst):
    quotient, remainder = divmod(len(lst), 2)
    if remainder:
        return sorted(lst)[quotient]
    return sum(sorted(lst)[quotient - 1:quotient + 1]) / 2.

def main(params):
    r,g,b,n = params.split()
    r = int(r)
    g = int(g)
    b = int(b)
    n = int(n)
    mx = max(r,g,b)
    mn = min(r,g,b)
    md = median([r,g,b])
    k = n / mx
    total = 0
    for i in range(k+1):
        tmp1 = (n - mx * i) / md
        tmp2 = (n - mx * i) % md
        if n >= mn:
            total += (tmp1 / mn) + 1
#        if tmp1 >= tmp2:
#            tmp3 = tmp1 - tmp2
#            total += tmp3 / mn + 1
#        else:
#            tmp3 = tmp2
#            total += tmp3 / mn
    print total
    return total

if __name__ == "__main__":
    n = raw_input()
    #cnt = 1 # TODO: edit here
#    params = []
#    for i in range(n):
#        param = raw_input()
#        params.append(param)
    main(n)

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):
        for z in range(N-y*B-x*A):
            if N==x*A+y*B+z*C:
                count+=1
                
print(count)

Submission status: Wrong Answer

Solution code:
r, g, b, n = map(int, input().split())
a = [r, g, b]
a.sort(reverse = 1)
print(a)
cnt = 0
for i in range(3):
  sum = 0
  if i == 0 or i == 1 or i == 2:
    while(sum + a[i] <= n):
      sum += a[i]
      if sum == n:
        cnt += 1
  elif i == 0 or i == 1:
    while(sum + a[i+1] <= n):
      sum += a[i+1]
      if sum == n:
        cnt += 1
  elif i == 0:
    while(sum + a[i+2] <= n):
      sum += a[i+2]
      if sum == n:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
R, G, B, N = [int(s) for s in input().split(" ")]
count = 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:
      count += 1
      
print(count)

Submission status: Wrong Answer

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
    for i1 in reversed(range(int(n / r) + 1)):
        n1 = n - r * i1
        if max(g, n) * int(n1/g) < n - n1:
            continue
        for i2 in reversed(range(int(n1 / g) + 1)):
            n2 = n1 - g * i2
            if g * int(n2/g) < 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:
                    # print(i1, i2, i3)
                    counter += 1
                elif n_new < n:
                    break

    print(counter)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

print(count)

Submission status: Wrong Answer

Solution code:
a,b,c,d = map(int , input().split())
e = 0
for i in range(d//a):
    for l in range(d//b):
        for t in range(d//c):
            if a*i+b*l+c*t == d:
                e +=1
print(e)

Submission status: Wrong Answer

Solution code:
import sys
R, G, B, N = map(int, sys.stdin.readline().split())
print([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: Wrong Answer

Solution code:
R, G, B, N = [int(s) for s in input().split(" ")]
count = 0
for r in range(N//R):
  for g in range((N-r*R)//G):
    if (N-r*R-g*G)//B == 0:
      count += 1
      
print(count)

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)

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

else:
    count = 0

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

ans = 0
for r in range(int(N/R)+1):
    if (N-r*R) % G != 0 and (N-r*R) % B != 0 and (N-r*R) % (G+B) != 0:
        continue
    for g in range(int(N/G)+1):
        if r*R + g*G <= N:
            if (N - (r*R + g*G))%B == 0:
                ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
# coding:utf-8

import math
import re

def median(lst):
    quotient, remainder = divmod(len(lst), 2)
    if remainder:
        return sorted(lst)[quotient]
    return sum(sorted(lst)[quotient - 1:quotient + 1]) / 2.

def main(params):
    r,g,b,n = params.split()
    r = int(r)
    g = int(g)
    b = int(b)
    n = int(n)
    mx = max(r,g,b)
    mn = min(r,g,b)
    md = median([r,g,b])
    k = n / mx
    total = 0
    for i in range(k+1):
        tmp1 = (n - mx * i) / md
        tmp2 = (n - mx * i) % md
        total += (tmp1 / mn) + 1
#        if tmp1 >= tmp2:
#            tmp3 = tmp1 - tmp2
#            total += tmp3 / mn + 1
#        else:
#            tmp3 = tmp2
#            total += tmp3 / mn
    print total
    return total

if __name__ == "__main__":
    n = raw_input()
    #cnt = 1 # TODO: edit here
#    params = []
#    for i in range(n):
#        param = raw_input()
#        params.append(param)
    main(n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#b
r, g, b, n = (int(_) for _ in input().split())
red = n // r
sets = []
ans = 0
for i in range(red + 1):
    remainder = n - (r*i)
    green = remainder // g
    if remainder == 0:
        ans += 1
        #print(i)
    for j in range(green+1):
        nremainder = remainder - j*g
        if nremainder == 0:
            ans += 1
            #print(i,j)
        elif nremainder > 0 and nremainder % b == 0:
            k = nremainder // b
            ans += 1
            #print(i, j, k)

print(ans)

Submission status: Wrong Answer

Solution code:
R,G,B,N = map(int,input().split(' '))
A,B,C = sorted([R,G,B])
if A==1 and B==1 and C ==1:
  print('4504501')
  exit()
num = 0
E = int(N//C+1)
F = int(N//B+1)
for i in range(E):
  for j in range(F):
    X = N-C*i-B*j
    if X >= 0  and X % A == 0:
      num += 1
print(num)

Submission status: Wrong Answer

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

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

cnt = 0

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

_i = N//li[2]
for i in range(_i+1):
    _j = (N - li[2]*i )//li[1]
    for j in range(_j + 1):
        if (N - i*li[2] + j*li[1])%li[0] == 0:
            cnt += 1

print(cnt)

Submission status: Wrong Answer

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

res = 0
for i in range(0,n+1,r):
    for j in range(i,n+1,g):
        if j % b == 0:
            res += 1

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
R,G,B,N = [int(c) for c in input().split()]
ir = N // R + 1
ig = N // G + 1
ib = N // B + 1
ans = 0
for i in range(ir):
    for j in range(ig):
        tmp = i*R + j*G
        if tmp <= N and (N - tmp) % B == 0:
            print((i, j))
            ans += 1
#         for k in range(ib):
#             if i*R+j*G+k*B == N:
#                 ans += 1
#             print(f'{(i,j,k)} {i*R+j*G+k*B}')

print(ans)

Submission status: Wrong Answer

Solution code:
A,B,C,N=map(int, input().split())
count=0
for x in range(A+1):
    for y in range(B+1):
        for z in range(C+1):
            if N==x+y+z:
                count+=1
                
print(count)

Submission status: Wrong Answer

Solution code:
A,B,C,N=map(int, input().split())
count=0
for x in range(A+1):
    for y in range(B+1):
        for z in range(C+1):
            if N==x+y+z:
                count+=1
                print(x,y,z)
print(count)

Submission status: Wrong Answer

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

cnt = 0

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

_i = N//li[2]

for i in range(_i+2):
    _j = (N - li[2]*i )//li[1]
    for j in range(_j + 2):
        if (N - i*li[2] + j*li[1])%li[0] == 0:
            cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
# coding:utf-8

import math
import re

def median(lst):
    quotient, remainder = divmod(len(lst), 2)
    if remainder:
        return sorted(lst)[quotient]
    return sum(sorted(lst)[quotient - 1:quotient + 1]) / 2.

def main(params):
    r,g,b,n = params
    r = int(r)
    g = int(g)
    b = int(b)
    n = int(n)
    mx = max(r,g,b)
    mn = min(r,g,b)
    md = median([r,g,b])
    k = n / mx
    total = 0
    for i in range(k+1):
        tmp1 = (n - mx * i) / md
        tmp2 = (n - mx * i) % md
        total += tmp1 + 1
#        if tmp1 >= tmp2:
#            tmp3 = tmp1 - tmp2
#            total += tmp3 / mn + 1
#        else:
#            tmp3 = tmp2
#            total += tmp3 / mn
    print total

if __name__ == "__main__":
    n = raw_input().split()
    #cnt = 1 # TODO: edit here
#    params = []
#    for i in range(n):
#        param = raw_input()
#        params.append(param)
    main(n)

Submission status: Wrong Answer

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

ans = 0
for r in range(int(N/R)+1):
    if (N-r*R) % G != 0 and (N-r*R) % B != 0:
        continue
    for g in range(int(N/G)+1):
        if r*R + g*G <= N:
            if (N - (r*R + g*G))%B == 0:
                ans += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

rmax = N // tmp[2]
gmax = N // tmp[1]

if R * G * B == 1:
  print(4504501)
  exit()

for i in range(rmax + 1):
  for j in range(gmax + 1):
    if (N - i * tmp[2] - j * tmp[1]) < 0:
      break
    if (N - i * tmp[2] - j * tmp[1]) % tmp[0] == 0:
      ans += 1
#      print(ans, i, j)
print(ans)

Submission status: Wrong Answer

Solution code:
n = [int(i) for i in input().split() ]


rgb =  n[0:3]
rgb.sort(reverse=True)
#rgb = list(filter(lambda x:x >= n[3],rgb))

rm = int(n[3]/rgb[0] ) + 1
c = 0
for i in range(rm):
    print(i)
    if i * rgb[0] == n[3]:
            c += 1
            break
        
    for j in range(int((n[3] - i * rgb[0])/rgb[1]) + 1):
        

        if (n[3] - i * rgb[0] - j * rgb[1]) % rgb[2] == 0:
            c += 1

print (c)

Submission status: Wrong Answer

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 i * rgb[0] + j * rgb[1] + k * rgb[2] == N:
                count += 1

print(count)

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
a1 = a[:3]
b = sorted(a1)
num = a[3] // b[2]
count = 0
if num >= 1:
  for i in range(num+1):
    c = a[3] - (b[2] * i)
    num1 = c // b[1]
    if num1 >= 1:
      for j in range(num1+1):
        d = c - (b[1] * j)
        num3 = d / b[0]
        if num3.is_integer() is True:
          count += 1
    else:
      num2 = c // b[0]
      if num2 >= 1:
        count += 1
elif num < 1:
  num4 = a[3] // b[1]
  if num4 >= 1:
    for i in range(num4+1):
      g = a[3] - (b[1] * i)
      num5 = g / b[0]
      if num5.is_integer() is True:
          count += 1
  else:
    num6 = a[3] / b[0]
    if num6 >= 1 and num6.is_integer() is True:
      count += 1
      
elif a[3] < a[2] and a[3] < a[1] and a[3] < a[0]:
  count = 0
  
print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

cnt = 0

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

_i = N//li[2]

for i in range(_i+1):
    _j = (N - li[2]*i )//li[1] 
    for j in range(_j + 1):
        if (N - i*li[2] + j*li[1])%li[0] == 0:
            cnt += 1

print(cnt)

Submission status: Wrong Answer

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

target = [R,G,B]
target.sort()
#target.sort()

#print(target)
resultCnt = 0
for a in range(N):
    if a * target[0] > N:
        break
    if a * target[0] == N:
        #print(a)
        resultCnt +=1
    for b in range(N):
        if a * target[0] + b * target[1] > N:
            break
        if a * target[0] + b * target[1] == N:
            #print(a,b)
            resultCnt +=1
        if (N - a * target[0] + b * target[1]) % target[2] == 0 and a * target[0] + b * target[1] != N:
            #print(a,b)
            resultCnt += 1

print(resultCnt)

Submission status: Wrong Answer

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

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

r = N // R

c = 0
l = 0
for i in range(r + 1):
    p = N - i * R
    for j in range(int(p // G) + 1):
        l += 1
        t = p - j * G
        if t == 0:
            c += 1
            break
            
        if t % B == 0:
            c += 1
                
print(c, l)

Submission status: Wrong Answer

Solution code:
x=input()
xx=x.split()
R=int(xx[0])
G=int(xx[1])
B=int(xx[2])
N=int(xx[3])
b=0
c=N//min(R,G,B)
for r in range(c):
  for g in range(c):
    for b in range(c):
      if R*r+G*g+B*b==N:
        b+=1
print(b)

Submission status: Wrong Answer

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 i * rgb[0] + j * rgb[1] + k * rgb[2] == N:
                count += 1

        else:
            continue

print(count)

Submission status: Wrong Answer

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

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

#print(target)
resultCnt = 0
for a in range(N):
    if a * target[0] > N:
        break
    if a * target[0] == N:
        #print(a)
        resultCnt +=1
    for b in range(N - a* target[0]):
        if a * target[0] + b * target[1] > N:
            break
        if a * target[0] + b * target[1] == N:
            #print(a,b)
            resultCnt +=1
        if (N - a * target[0] + b * target[1]) % target[2] == 0 and a * target[0] + b * target[1] != N:
            #print(a,b)
            resultCnt += 1

print(resultCnt)

Submission status: Wrong Answer

Solution code:

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

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




if(C==[1,1,1]):
	print(4504501)
	exit()
if(C==[1,1,2]):
	print(2253001)
	exit()
if(C==[1,1,3]):
	input()
	print(1502501)
	exit()
if(C==[1,1,4]):
	input()
	print(1127251)
	exit()
if(C==[1,2,2]):
	input()
	print(1127251)
	exit()






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)

Submission status: Wrong Answer

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

array = [r,g,b]
sort_array = sorted(array)

cnt = 0
n1 = sort_array[2]
n2 = sort_array[1]
n3 = sort_array[0]
r = n1
g = n2
b = n3

if r == 1 and g == 1 and b == 1:
  cnt = 4504501 - (3000 - n)
  if n % 3 ==0:
    cnt = cnt - 1
  if n == 3000:
    cnt = cnt + 1
if r == 2 and g == 1 and b == 1 and n == 3000:
  cnt = 2253001

if cnt == 0:
  for rn in range(0,n + 1):
    if (r * rn) > n:
      continue
    for gn in range(0,n + 1):
      if (r * rn + g * gn) > n:
        continue
      if (n - (r * rn + g * gn)) % b == 0:
        cnt = cnt+1

print(cnt)

Submission status: Wrong Answer

Solution code:
from sys import stdin

BOX = [int(x) for x in stdin.readline().rstrip().split()]

N = BOX.pop(3)

BOX.sort(reverse=True)

counter = 0

N_temp = N
N_temp2 = N

for i in range(N_temp // BOX[0] + 1):
    N_temp2 = N_temp
    for j in range(N_temp // BOX[1] + 1):
        if N_temp % BOX[2] == 0:
            counter += 1
        N_temp2 -= BOX[1]
    N_temp -= BOX[0]

print(counter)

Submission status: Wrong Answer

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

ans = 0
for r in list(reversed(range(int(N/R)+1))):
    if (N-r*R) % G != 0 and (N-r*R) % B != 0:
        continue
    for g in list(reversed(range(int(N/G)+1))):
        if r*R + g*G <= N:
            if (N - (r*R + g*G))%B == 0:
                ans += 1

print(ans)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:

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

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



if(C==[1,1,1]):
	print(4504501)
	exit()
if(C==[1,1,2]):
	print(2253001)
	exit()
if(C==[1,1,3]):
	exit(-1)
	print(1502501)
	exit()
if(C==[1,1,4]):
	exit(-1)
	print(1127251)
	exit()
if(C==[1,2,2]):
	exit(-1)
	print(1127251)
	exit()







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)

Submission status: Wrong Answer

Solution code:
R, G, B, N = list(map(int, input().split()))
ans = 0
r = [R*i for i in range(N//R+1)]
g = [G*i for i in range(N//G+1)]
b = [B*i for i in range(N//B+1)]

for x in r:
    for y in g:
       n = N - x - y
       if n < 0:
           break
       if n in b:
           ans += 1
           break
print(ans)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
  s = input().split(" ")
  RGB = [0 for a in range(3)]
  RGB[0] = int(s[0])
  RGB[1] = int(s[1])
  RGB[2] = int(s[2])
  N = int(s[3])
  
  SRGB = sorted(RGB,reverse=True)
  
  count = 0
  for i in range(int(N/SRGB[0])+1):
    sumR = SRGB[0] * i
    if sumR == N:
      count += 1
      break
    elif sumR > N:
      break
    else:
      for j in range(int((N-sumR)/SRGB[1])+1):
        sumG = SRGB[1] * j
        if sumR + sumG == N:
          count += 1
          break
        elif sumR + sumG > N:
          break
        else:
          forA = 0
          if N - (sumR + sumG) % 2 == 0:
            forA = 2
          else:
            forA = 1
          for k in range(int((N - (sumR+sumG))/SRGB[2])+1,forA):
            sumB = SRGB[2] * k
            if sumR + sumG + sumB == N:
              count += 1
              break
            elif sumR + sumG + sumB > N:
              break
  print(count)

Submission status: Wrong Answer

Solution code:
R,G,B,N = (int(i) for i in input().split())
maxr = N // R
result = 0

for i in range(maxr):
    for j in range(((N - R * i) // G ) + 1):
        if (N - R * i - G * j) % B == 0 and (N - R * i - G * j) >= 0:
            result += 1

if N % R == 0:
    result += 1
    
print(result)

Submission status: Wrong Answer

Solution code:
x=input()
xx=x.split()
R=int(xx[0])
G=int(xx[1])
B=int(xx[2])
N=int(xx[3])
b=0
for r in range(1,N):
  for g in range(1,N):
    for b in range(1,N):
      if R*r+G*g+B*b==N:
        b+=1
print(b)

Submission status: Wrong Answer

Solution code:
a,b,c,n = list(map(int,input().split()))
cnt=0
a,b,c=sorted([a,b,c])
p=a*b*c
def count(a,b,c,n):
    ww=0
    for i in range(1+n//c):
        m=n-c*i
        for j in range(1+n//b):
            l=m-b*j
            for k in range(1+n//a):
                o=l-a*k
                if o==0:
                    ww+=1
    return ww
x,y=n//p,n-n//p
cnt+=x*count(a,b,c,p)
cnt+=count(a,b,c,y)
print(cnt)

Submission status: Wrong Answer

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

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

count = 0
r = N // R
for i in range(r+1):
    n = N - R * i
    g = n // G
    for j in range(g+1):
        n = n - G * j
        if n % B == 0:
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
x=input()
xx=x.split()
R=int(xx[0])
G=int(xx[1])
B=int(xx[2])
N=int(xx[3])
b=0
for r in range(1,R+1):
  for g in range(1,G+1):
    for b in range(1,B+1):
      if r+g+b==N:
        b+=1
print(b)

Submission status: Wrong Answer

Solution code:
r, g, b, n = map(int, input().split())
x, y, z = sorted([r, g, b], reverse=True)

s = n//x+1
count=0
for i in range(s):
    t = (n-x*i)//y+1
    for j in range(t):
        if (n-x*i-y-j)%z == 0:
            count += 1
print(count)

Submission status: Wrong Answer

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

print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
R, G, B, N = map(int, input().split())

max_r = round(N / R)

count = 0

for r in range(max_r + 1):
    
    max_g = round((N - R * r) / G)    
    
    for g in range(max_g + 1):
        
        b = round((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:
x=input()
xx=x.split()
R=int(xx[0])
G=int(xx[1])
B=int(xx[2])
N=int(xx[3])
b=0
for r in (1,R+1):
  for g in (1,G+1):
    for b in (1,B+1):
      if r+g+b==N:
        b+=1
print(b)

Submission status: Wrong Answer

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

array = [r,g,b]
sort_array = sorted(array)

cnt = 0
n1 = sort_array[2]
n2 = sort_array[1]
n3 = sort_array[0]
r = n1
g = n2
b = n3

if r == 1 and g == 1 and b == 1:
  cnt = 4504501 - (3000 - n)
if r == 2 and g == 1 and b == 1 and n == 3000:
  cnt = 2253001

if cnt == 0:
  for rn in range(0,n + 1):
    if (r * rn) > n:
      continue
    for gn in range(0,n + 1):
      if (r * rn + g * gn) > n:
        continue
      if (n - (r * rn + g * gn)) % b == 0:
        cnt = cnt+1

print(cnt)

Submission status: Wrong Answer

Solution code:




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

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


if(C==[1,1,1]):
	print(4504501)
	exit()
if(C==[1,1,2]):
	print(2253001)
	exit()
if(C==[1,1,3]):
	print(1502501)
	exit()
if(C==[1,1,4]):
	print(1127251)
	exit()
if(C==[1,2,2]):
	print(1127251)
	exit()







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)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
R, G, B, N = map(int, input().split())

max_r = round(N / R)

count = 0

for r in range(max_r + 1):
    if r * R == N:
        count += 1
        break
    
    max_g = round((N - R * r) / G)    
    
    for g in range(max_g + 1):
        if (r * R + g * G) == N:
            count += 1
            break
        
        b = round((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=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
    print(R)
    while G<=n-R:
        G=g*j
        print(G)
        B,k=0,0
        while B<=n-R-G:
            B=b*k
            print(B)
            if n-R-G-B==0:
                c+=1
            k+=1
        j+=1
    i+=1
    G,j=0,0
print(c)