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: Accepted

Solution code:
def trans(n, dp, color):
    for i in range(n-color+1):
        dp[i+color] += dp[i]
    return dp

def main():
    r, g, b, n = [int(i) for i in input().split()]
    dp = [0 for i in range(n+1)]
    dp[0] = 1
    dp = trans(n, dp, r)
    dp = trans(n, dp, g)
    dp = trans(n, dp, b)
    print(dp[-1])

main()

Submission status: Accepted

Solution code:
r,g,b,n = map(int, input().split(" "))
l = sorted([r,g,b])
count=0
for i in range(n+1):
    for j in range(n+1):
        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: Accepted

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

Submission status: Accepted

Solution code:
r,g,b,n = map(int, input().split(" "))
l = sorted([r,g,b])
count=0
for i in range(int(n/l[2])+1):
    for j in range(int(n/l[1])+1):
        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: Accepted

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)
    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
            if n2 % b == 0:
                counter += 1
    print(counter)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))



def main():
    R, G, B, N = i2nn()
    #a = []
    cnt = 0
    R, G, B = sorted((R, G, B), reverse=True)
    for r in range(N // R + 1):
        for g in range((N - R * r) // G + 1):
            #print([r, g, 0], N - R * r - G * g)
            if (N - R * r - G * g) % B == 0:
                cnt += 1
                #a.append([r,g,(N - R * r - G * g) // B])
    #print(a)
    print(cnt)
main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
r,g,b,n = map(int,input().split())
a = [0 for i in range(n+1)]
a[0] = 1
for j in range(n+1-r):
    a[j+r]=a[j]
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: Accepted

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]=a[j]
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: Accepted

Solution code:
r,g,b,n = map(int,input().split())
a = [0]*(n+1)
a[0] = 1
for j in range(0,n+1-r,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: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
R, G, B, N = map(int, input().split())
i = 0
for r in range(N // R + 1):
    Rr = r * R
    for g in range(N // G + 1):
        Gg = g * G
        Bb = N-Rr-Gg
        if Bb < 0:
            break
        if Bb % B == 0:
            i += 1
print(i)

Submission status: Accepted

Solution code:
def solve():
    R, G, B, N = [int(_) for _ in raw_input().split()]
    X = min(R, G, B)
    if X == R:
        Y = min(G,B)
        Z = max(G,B)
    elif X == G:
        Y = min(R,B)
        Z = max(R,B)
    else:
        Y = min(R,G)
        Z = max(R,G)
    ret = 0
    for i in range(N/Z, -1, -1):
        for j in range((N - i * Z)/Y, -1, -1):
            sum2 = N - i * Z - j * Y
            if sum2 % X == 0:
                ret += 1
    print str(ret)

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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):
    Rr = R*r
    for g in range(N//G+1):
        Gg = G*g
        Bb = N-Rr-Gg

        if Bb < 0:
            break
        if Bb%B == 0:
            ans += 1
 
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding:utf-8

import numpy as np


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

    R = np.arange(0, n + 1, r)
    G = np.arange(0, n + 1, g)

    RG = np.add.outer(R, G).flatten()

    RG = RG[RG <= n]
    RG = RG[(n - RG) % b == 0]
    print(len(RG))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
def inpl(): return list(map(int, input().split()))

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
for i in range(N//R+1):
    g_range = (N - RGB[0]*i)//RGB[1]
    for j in range((N-R*i)//G+1):
        rem = N - R*i - G*j
        if rem % B == 0: 
            cnt += 1
print(cnt)

Submission status: Accepted

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

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

print(sum((1 for c1 in range(0, N+1, C[0]) for c12 in range(c1, N+1, C[1]) if (N - c12) % C[2] == 0 )))

Submission status: Accepted

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

lst = [r, g, b]
lst.sort()
r = lst[2]
g = lst[1]
b = lst[0]

rlim = n//r
glim = n//g

cnt = 0

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

Submission status: Accepted

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

print(solve())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: UTF-8
import sys
sys.setrecursionlimit(10**5)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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

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

print(cnt)

Submission status: Accepted

Solution code:
r,g,b,n=map(int,input().split());print(sum((n-j)%b<1for i in range(0,n+1,r)for j in range(i,n+1,g)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
for i in range(N+1):
  for j in range(N+1):
    k = N - R*i - G*j
    if k >= 0:
      if k%B == 0:
        cnt += 1
    else:
      break
print(cnt)

Submission status: Accepted

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

cnt = 0
for i in range(0, N+1, R):
  for j in range(0, N+1, G):
    k = N - i - j
    if k >= 0:
      if k%B == 0:
        cnt += 1
    else:
      break
print(cnt)

Submission status: Accepted

Solution code:
def main():
    r,g,b,n = map(int, input().split())
    tmp = [r,g,b]
    r,g,b = sorted(tmp, reverse=True)
    res = 0
    for i in range(n//r + 1):
        if i*r > n:
            break
        for j in range(n//g + 1):
            if r*i + g*j > n:
                break
            if (n-(r*i + g*j)) % b==0:
                res += 1           
    print(res)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
                                    #入力整数1つ
r,g,b,n= (int(i) for i in input().split())       #入力整数横2つ以上

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
r,g,b,n=map(int,input().split());print(sum((n-i-j)%b<1for i in range(0,n+1,r)for j in range(0,n+1,g)if n>=i+j))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ok)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, d = (int(_) for _ in input().split())  

res = 0
for i in range(0,d+1,a):
    for ii in range(0,d-i+1,b):
        if (d - i - ii) % c == 0:
            res += 1

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

c = 0

for i in range(n//r + 1):

	n1 = n-r*i


	for j in range(n1//g + 1):

		n2 = n1 - g * j


		if(n2%b == 0):
			c += 1


print(c)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:

R, G, B, N = map(int, input().split())
rgb = []
for i in range(N + 1):
    for j in range(N - i + 1):
        key = i * R + j * G
        key = N - key
        if key % B == 0 and key / B >= 0:
            rgb.append([i, j, key // B])

#print(rgb)
print(len(rgb))

Submission status: Accepted

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

Submission status: Accepted

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: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def xx(a,b,c):
    ans=0
    if c%a == 0:
        ans += 1
    while c>0:
        if c%b == 0:
            ans+=1
        c -= a
    return ans


r,g,b,n = map(int,input().split())
ans = 0
if n%r==0:
    ans += 1
while n>0:
    ans += xx(g,b,n)
    n -= r
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
I=lambda:map(int,input().split())
R,G,B,N=I()
r=0
rG = N-np.array(range(N//G+1))*G
for i in range(N//R+1):
    rB=rG-i*R
    r+=np.sum((rB>=0)&(rB%B==0))
print(r)

Submission status: Accepted

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

Submission status: Accepted

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:
            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: Accepted

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


def main():
    r, g, b, n = map(int, input().split())
    comb = list()
    ans = 0

    for i in range(3000 + 1):
        for j in range(3000 + 1):
            comb.append(r * i + g * j)

    for c in comb:
        if (n - c) >= 0 and (n - c) % b == 0:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(N+1):
    r = R*i
    for j in range(N+1):
        g = G*j
        k = int((N-r-g)/B)
        if 0 <= k and r+g+(B*k) == N:
            count += 1

print(count)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

#num = int(input())
#S = str(input())

r=l[0]
g=l[1]
b=l[2]
N=l[3]

Num=3000

sum = 0
for i in range(N//r+1):
    for j in range(N//g+1):
        _b=N-i*r-j*g
        if _b<0:
            break
        if _b%b==0:
            sum+=1
print(sum)

Submission status: Accepted

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) if  (N -(r*R + g*G))%B == 0]))

Submission status: Accepted

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

Submission status: Accepted

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

ans=0

for count_r in range(N // R + 1):
    currnt_N = N - R * count_r
    for count_g in range(currnt_N // G + 1):
        #pass
        currnt_N = N - R * count_r - G * count_g
        if currnt_N % B == 0:
            ans += 1
            
print(ans)

Submission status: Accepted

Solution code:
R,G,B,N=map(int,input().split())
count=0
wa=0
for i in range(int(N/R)+1):
    for j in range(int((N-i*R)/G)+1):
        b=(N-i*R-j*G)/B
        if b>=0 and float.is_integer(b)==True:
            count=count+1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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
    elif num1 == 0:
      num2 = c / b[0]
      if num2 >=0 and num2.is_integer() is True:
        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 >= 0 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: Accepted

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

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

Submission status: Accepted

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[0])//boxes[1] +1):
        if (n-(i*boxes[0]+j*boxes[1]))%boxes[2] == 0:
            ans += 1
print(ans)

Submission status: Accepted

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

cnt = 0

for red in range(n // r + 1):

    for green in range((n - r * red) // g + 1):

        blue = n - red * r - green * g

        if blue >= 0 and blue % b == 0:

            cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
from sys import stdin
r, g, b, n = [int(x) for x in stdin.readline().rstrip().split()]

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

print(ans)

Submission status: Accepted

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

ans = int(0)
x = int(N//R)

for i in range(x+1):
    t = N-i*R
    y = int(t//G)
    for j in range(y+1) :
        s = int(t-G*j)
        if s%B==0 : ans +=1

print(ans)

Submission status: Accepted

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

if R * G * B == 1:
  for i in range(N + 1):
    ans += N + 1 - i
  print(ans)
  exit()

for i in range(rmax + 1):
  for j in range(gmax + 1):
    if (N - i * R - j * G) < 0:
      break
    if (N - i * R - j * G) % B == 0:
      ans += 1
#      print(ans, i, j)
print(ans)

Submission status: Accepted

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

c = 0
for r in range(N//R, -1, -1): 
    new1 = N - r*R
    for g in range(new1//G, -1, -1):
        new2 = new1 - g*G
        if new2%B == 0:
            c +=1
    
print(c)

Submission status: Accepted

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):
    for j in range((N-i*L[0])//L[1]+1):
        if (N-i*L[0]-j*L[1])%L[2] == 0:
                ans += 1

print(ans)

Submission status: Accepted

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

count=0
for i in range(0, n+x, x):
    for j in range(i, n+y, y):
        res = n-j
        if res%z == 0:
            count += 1
print(count)

Submission status: Accepted

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

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

counter = 0
for r in range(int(N/R) + 1):
    for g in range(int((N - r)/G) + 1):
        t = R*r + G*g
        if t > N:
            break
        if (N - t) % B == 0:
            counter += 1

print(counter)

Submission status: Accepted

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

Submission status: Accepted

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


def main():
    R, G, B, N = [int(ele) for ele in input().split()]
    ans = 0
    for i in range(N+1):
        tmp = N - i*R

        for j in range(N+1):
            tmp2 = tmp - j*G
            if tmp2 < 0:
                break
            if tmp2 % B == 0:
                ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
line = [int(x) for x in input().split(" ")]
r = line[0]
g = line[1]
b = line[2]
n = line[3]
m = [r,g,b]
m.sort()
m.reverse()

res = 0

ro1 = list(range(math.floor(n / m[0]) + 1))
ro1.reverse()

for i in ro1:
    p = i * m[0]
    ro2 = list(range(math.floor((n - p) / m[1]) + 1))
    ro2.reverse()
    for j in ro2:
        q = p + j * m[1]

        if (n - q) % m[2] == 0:
            res += 1
print(res)

Submission status: Accepted

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: Accepted

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

#sum_rg = collections.Counter()
sum_rg = collections.defaultdict(int)

for i in range(n + 1):
    if n < r*i:
        break
    for j in range(n + 1):
        if n < r*i + g*j:
            break
        sum_rg[r*i + g*j] += 1

ans = 0
for k in range(n + 1):
    if n < b*k:
        break
    ans += sum_rg[n - b*k]

#print(sum_rg)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    R,G,B,N = list(map(int,input().split())) 
    RGBs = sorted([R,G,B],reverse=True)
    count = 0
    if N < min(R,G,B):
        pass
    else:
        for i in range(int(N/RGBs[0])+1):
            O = N - i*RGBs[0]
            for j in range(int(O/RGBs[1])+1):
                P = O - j*RGBs[1]
                if P%RGBs[2] == 0:
                    count += 1
    print(count)


solve()

Submission status: Accepted

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(int((N+2)*(N+1)/2))
  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)