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

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

Submission status: Accepted

Solution code:
def li():
    return list(map(int, input().split()))


def combination2(a, b, n):
    # print('call 2: ', a, b, n)
    com2 = 0
    a_quot = n // a + 1
    for j in range(a_quot):
        com2 = com2 + combination1(b, n - j * a)
    return com2


def combination1(a, n):
    # print('call 1: ', a, n)
    if n % a == 0:
        return 1
    else:
        return 0


[r, g, b, n] = li()
r_quot = n // r + 1
com_num = 0
for i in range(r_quot):
    com_num = com_num + combination2(g, b, n - i * r)
print(com_num)

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
def main():
    R, G, B, N = map(int, input().split())

    count = 0
    for r in range(3001):
        if r*R > N:
            break

        for g in range(3001):
            rest = N - (r*R + g*G)
            if rest < 0:
                break
            if rest % B == 0:
                count += 1
    print(count)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = 0
for i in range((N//R)+1):
    temp = N - i*R
    for j in range((temp//G)+1):
        temp2 = N - i*R - j*G
        if temp2 % 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//G+1):
        n = N - R*i - G*j
        if n < 0:
          break
        if n % B == 0:
            ans += 1
print(ans)

Submission status: Accepted

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

for i in range(0, N//R+1):
    for j in range(0, (N-R*i)//G + 1):
        if (N-R*i-G*j) % B == 0:
            cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import numpy as np
r,g,b,n = map(int, input().split())
# 大きい順にやっていけばいけるけど...?

m1,m2,m3 = sorted([r,g,b])
count = 0
for k in range((n // m3)+1):
  now_n = n-k*m3
  for u in range((now_n // m2)+1):
    if (now_n - m2*u) % m1 == 0:
      count += 1
print(count)

Submission status: Accepted

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

ct = 0

for r in range(int(N/R)+1):
  N_ = N - R*r
  if N_==0:
    ct+=1
    continue
  for g in range(int(N_/G)+1):
    N__ = N_ - G*g
   	
    if N__%B == 0:
      ct+=1
      
print("{0}".format(ct))

Submission status: Accepted

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

a = sorted([r,g,b])
count = 0
for i in range(0,n//a[2]+1):
    for j in range(0,(n-i*a[2])//a[1]+1):
        if (n-a[2]*i-a[1]*j)%a[0] == 0:
            count += 1
print(count)

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
r,g,b,n = map(int, input().split())

cnt = 0
for ri in range(n+1):
    if r*ri>n:
        break
    for gi in range(n+1):
        x = n - r*ri - g*gi
        if x<0:
            break
        if x%b==0:
            cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import math

R,G,B,N=map(int,input().split())
ans=0
x=[R,G,B]
x.sort(reverse=True)

for i in range(N//x[0]+1):
    n=N-i*x[0]
    for j in range(n//x[1]+1):
        if (n-j*x[1])%x[2]==0: ans+=1

print(ans)

Submission status: Accepted

Solution code:
nums = list(map(int, input().split()))
R, G, B, N = nums[0], nums[1], nums[2], nums[3]

cnt = 0
for i in range(N // R + 1):
    rem = N - i*R
    for j in range(rem // G + 1):
        rem = N - i*R - j*G
        if rem % 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:
import sys
input = sys.stdin.readline

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

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

print(counter)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

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

print(ans)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy3


def solve(r, g, b, n):
    res = 0
    for i in range(n // r + 1):
        rest = n - i * r
        for j in range(rest // g + 1):
            rest2 = n - (i * r + j * g)
            if rest2 >= 0 and rest2 % b == 0:
                res += 1
    return res


def main():
    r, g, b, n = (int(z) for z in input().split())
    res = solve(r, g, b, n)
    print(res)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = 0


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

Submission status: Accepted

Solution code:
R, G, B, N = map(int,input().split())
count = 0
i_range = N//R+1
j_range = N//G+1

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3


def solv(r, g, b, n):
    ans = 0
    r, g, b = sorted([r, g, b])
    for bn in range(n // b + 1):
        n1 = n - bn * b
        for gn in range(n1 // g + 1):
            n2 = n1 - gn * g
            if n2 % r == 0:
                ans += 1
    return ans


if __name__ == '__main__':

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

    ans = solv(r, g, b, n)

    print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(R: int, G: int, B: int, N: int):
    ret = 0
    for r in range((N // R) + 1):
        rc = R * r
        for g in range((N // G) + 1):
            gc = G * g
            bc = N - rc - gc
            if (0 <= bc) and  (bc % B == 0):
                ret += 1
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    result = solve(R, G, B, N)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

for r in range(N+1):
    N2=N-r*R
    if N2<0:
        break
    for g in range(N+1):
        N3=N2-g*G
        if N3<0:
            break
        if N3%B==0:
            result+=1

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
R,G,B,N = map(int, input().split())
ans = 0
for r in range(N//R+1):
    A = N-(r*R)
    for g in range(A//G+1):
        if (A -(g*G))%B == 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+1):
    t1 = N - r*R
    if t1 < 0: break
    for g in range(N+1):
        t2 = t1 - g*G
        if t2 < 0: break
        if t2 % B == 0: ans += 1

print(ans)

Submission status: Accepted

Solution code:
import math
r, b, g, n = map(int, input().split(' '))
ans = 0
# only r
r1 = int(math.ceil(n/r))
b1 = int(math.ceil(n/b))
g1 = int(math.ceil(n/g))

# print(r1, b1, g1)


for x in range(r1 + 1):
    for y in range(b1 + 1):
        tmp = n
        tmp -= x * r
        tmp -= y * b

        

        if tmp >= 0 and tmp % g == 0:
            ans += 1

        # print(x, y, tmp/g)

print(ans)

Submission status: Accepted

Solution code:
R,G,B,N = list(map(int,input().split()))
r_max = N//R+1
ans = 0
for r in range(r_max):
	g_max = (N-r*R)//G+1
	for g in range(g_max):
		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())

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

print(cnt)

Submission status: Accepted

Solution code:
R,G,B,N = map(int,input().split())
cnt = 0
for r in range(3001):
    if R*r <= N:
        for g in range(3001):
            if N - R*r -G*g >= 0:
                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())
import math
ans=0
a=math.floor(N/R)
for i in range(a+1):
    nokori=N-R*i
    b=math.floor(nokori/G)
    for j in range(b+1):
        nokori2=nokori-j*G
        if nokori2%B==0:
            ans+=1
        else:
            pass
print(ans)

Submission status: Accepted

Solution code:
import sys

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

count = 0

for r in range(int(N/R) + 1):
    N1 = N - R*r
    for g in range(int(N1/G) + 1):
        N2 = N1 - G*g
        if N2 % B == 0:
            count += 1
        #for b in range(int(N2/B) + 1):
        #if r*R + g*G + b*B == N:
        #count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input().split()
r,g,b,n=int(s[0]),int(s[1]),int(s[2]),int(s[3])
k = [r,g,b]
k.sort()
a,b,c=k[0],k[1],k[2]
co = 0
for i in range(n//c+1):
    p = n-i*c
    for j in range(p//b+1):
        q = p-j*b
        if q>=0 and q%a==0:
            co+=1
print(co)

Submission status: Accepted

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

for r in range(n+1):
    for g in range(n+1):
        b = n - R*r - G*g
        if 0 <= b <= n and b % B == 0:
            ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

cnt = 0
for i in range(N // R + 1):
    r = i * R
    for j in range((N - r) // G + 1):
        g = j * G

        b = N - r - g

        if b % B == 0:
            cnt += 1

print(cnt)

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:
r,g,b,n = map(int,input().split())
R = int(n/r)
G = int(n/g)
ans = 0
for i in range(0,R+1):
    for j in range(0,G+1):
        temp = i*r+j*g
        if (n-temp)%b==0 and n>=temp:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:


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

def submit():
    r, g, b, n = read_input()

    r_max = n // r
    g_max = n // g

    count = 0
    for rc in range(r_max + 1):
        for gc in range(g_max + 1):
            rest = n - (r*rc) - (g*gc)
            if rest < 0:
                continue

            bc, remain = divmod(rest, b)
            if remain == 0:
                count += 1

    print(count)

if __name__ == '__main__':
    submit()

Submission status: Accepted

Solution code:
R, G, B, N = [int(i) for i in input().split()]
ans = 0
for r in range(3001):
    for g in range(3001):
        mod = N - r * R - g * G
        if mod >= 0 and mod % 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):
  rest = n - r * i
  for j in range(rest // g + 1):
    p = rest - g * j
    if p % b == 0:
      ans += 1
print(ans)

Submission status: Accepted

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

count = 0

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

print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(R: int, G: int, B: int, N: int):
    ans = 0
    for i in range(0, N+1, R):
        for j in range(0, N+1, G):
            x = N - i - j
            if(0 <= x and x%B == 0):
                ans += 1

    print(ans)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    R = int(next(tokens))  # type: int
    G = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(R, G, B, N)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
# import numpy as np
# import math
# import fractions
# import sys
# sys.setrecursionlimit(100000)
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]

R,G,B,N = [int(x) for x in stdin.readline().rstrip().split()]

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

Submission status: Accepted

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

ans=0
for i in range(0,N+1,R):
  for j in range(i,N+1,G):
    if (N-j)%B==0:
      ans+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def f(r, g, b, n):
    cnt = 0
    for rn in range(n // r + 1):
        for gn in range((n - r * rn) // g + 1):
            if (n - r * rn - g * gn) % b == 0:
                cnt += 1
    print(cnt)

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

Submission status: Accepted

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

result = 0

for left in range(N, -1, -R):
    for x in range(left, -1, -G):
        if x % B == 0:
            result += 1

print(result)

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

Submission status: Accepted

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

ans = 0
for r in range(int(N / R) + 1):
  for g in range(int((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())

cnt = 0
for i in range(N+1):
    for j in range(N+1):
        k = N - R*i- G*j
        if k<0 or k % B != 0 : continue
        cnt += 1
            
print(cnt)

Submission status: Accepted

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

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

ans = 0
for  a in range(1 + N // boxes[0]):
    for b in range(1 + (N - a*boxes[0]) // boxes[1]):
        if((N - a*boxes[0] - b*boxes[1]) % boxes[2] == 0):
            ans += 1  
print(ans)

Submission status: Accepted

Solution code:

R, G, B, N = list(map(int, input().split()))
cnt = 0
rmax = N//R
gmax = N//G
bmax = N//B
for r in range(rmax+1):
    for g in range(gmax+1):
        temp = N-r*R-g*G
        if temp < 0:
            continue
        if temp%B == 0:
            cnt += 1
print(cnt)

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//G+1):
        if (N-r*R-g*G)<0:
            break
        elif (N-r*R-g*G)%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(3001):
    for g in range(3001):
        remain = N - (r*R + g*G)
        if remain >= 0:
            if remain % B == 0:
                ans += 1
        else:
            break
print(ans)

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

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


print(cnt)

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 - i):
        t = i * R + j * G
        if t <= N and (N - t) % B == 0: ans += 1
print(ans)

Submission status: Accepted

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

ans = 0
rmax = n // R
for i in range(rmax + 1):
    gmax = (n - R * i) // G
    for j in range(gmax + 1):
        if (n - R * i - G * j) % B == 0:
            ans += 1
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

ans = 0


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

Submission status: Accepted

Solution code:
# diverta 2019 Programming Contest
# https://atcoder.jp/contests/diverta2019
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().rstrip() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    R, G, B, N = i2nn()
    c = 0
    for r in range(N+1):
        rr = r * R
        if rr > N:
            break
        for g in range(N+1):
            gg = g * G
            if rr + gg > N:
                break
            n2 = N - rr - gg
            if n2 % B == 0:
                c += 1
    print(c)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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):
            #print(i,j)
            count+=1

print(count)

Submission status: Accepted

Solution code:
R, G, B, N = map(int, 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())
count = 0
for r in range(N//R+1):
    remain = N-R*r
    for g in range(remain//G+1):
        left = remain-G*g
        if left%B == 0:
            count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def main():
    buf = input()
    buflist = buf.split()
    R = int(buflist[0])
    G = int(buflist[1])
    B = int(buflist[2])
    N = int(buflist[3])
    combination = 0
    for i in range(3001):
        if i * R > N:
            break
        for j in range(3001):
            if i * R + j * G > N:
                break
            if (N - (i * R + j * G)) % B == 0:
                combination += 1
    print(combination)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(num)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
AtCoder B
"""

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = int(input()) for _ in range(N) # 1 row N column

# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']

def main():
    R, G, B, N = list(map(int,input().split()))
    tmp=0
    rb=0
    while rb*R<=N:
        ball=rb*R
        gb=0
        while gb<N-rb*R+1:
            ball_g=gb*G
            gball=ball_g+ball
            if N>=gball and (N-gball)%(B)==0:
                tmp+=1
            gb+=1
        rb+=1

    print(tmp)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# N = int(input())
# A = [int(x) for x in input().split()]
# from collections import defaultdict
# dd = defaultdict(lambda: 0)

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

cnt = 0

for r in range(1 + N // R):
    for g in range(1 + N // G):
        rest = N - (r * R + g * G)

        if rest >= 0 and rest % B == 0:
            cnt += 1
            # print("{}, {}".format(r,g))

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

def main():
    input = sys.stdin.readline
    R, G, B, N = map(int, input().split())
    ans = 0
    for i in range(N//R+1):
        for j in range(N//G+1):
            rest = N - R*i - G*j
            if rest >= 0 and rest % B == 0:
                ans += 1

    return ans


if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
R,G,B,N=map(int,input().split())
L=sorted([R,G,B])
M=N//L[2]
ans=0
for i in range(M+1):
  n=N-i*L[2]
  MM=n//L[1]
  for j in range(MM+1):
    ans+= 1 if (n-j*L[1])%L[0]==0 else 0
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//G+1):
        rest=N-R*i-G*j
        if rest>=0 and rest%B==0 :
            ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0:
        a, b = b, a % b
    return b
  
def solve():
    R, G, B, N = map(int, line_input())
    ans = 0
    for r in range(N // R + 1):
        left = N - r * R
        for g in range(left // G + 1):
            if (left - g * G) % B == 0: ans += 1
    print(ans)

    return 0
  
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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 - r * R - G * g
        if b >= 0 and b % B == 0:
            cnt += 1
print(cnt)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

z = 0
for r in range(3001):
    rR = r * R
    if rR > N:
        break
    for g in range(3001):
        gG = g * G
        if rR + gG > N:
            break
        if (N - rR - gG) % B == 0:
            z = z + 1

print(z)

Submission status: Accepted

Solution code:
#B問題
R,G,B,N=map(int,input().split())
count=0
nr=int(N/R)
for i in range(nr+1):
    N1=N-i*R
    ng=int(N1/G)
    for j in range(ng+1):
        N2=N1-j*G
        if N2%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+1):
    if i % R:
        continue
    for j in range(0, N-i+1):
        if j % G:
            continue
        if (N - i - j) % B:
            continue
        ans += 1
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy3

import math, itertools, operator
from math import *
from math import factorial as fact
from itertools import permutations, combinations
from functools import reduce
from statistics import mean, median, median_low, median_high, mode
# Before Python 3.5
from fractions import gcd

#import numpy
#import scipy, scipy.special
#from sympy import isprime, nextprime
#from sympy.ntheory import factorint

inf = float('inf')

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

def perm(a, b):
    import scipy.special
    return scipy.special.perm(a, b, exact = True)

def comb(a, b):
    import scipy.special
    return scipy.special.comb(a, b, exact = True)

def dfact(n):
    import scipy.special
    return scipy.special.factorial2(n, exact = True)

def prod(l):
    return reduce(operator.mul, l)

def input_ints(inp = input, sep = ' ', conv = int):
    return map(conv, inp().split(sep = sep))

################################################################################


R, G, B, N = input_ints()

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

print(cnt)

Submission status: Accepted

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

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

print(score)