Problem:


Score : 200 points

Problem Statement

Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:

Red boxes, each containing R red balls

Green boxes, each containing G green balls

Blue boxes, each containing B blue balls

Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes.
How many triples of non-negative integers (r,g,b) achieve this?

Constraints

All values in input are integers.

1 \leq R,G,B,N \leq 3000

Input

Input is given from Standard Input in the following format:

R G B N

Output

Print the answer.

Sample Input 1

1 2 3 4

Sample Output 1

4

Four triples achieve the objective, as follows:

(4,0,0)

(2,1,0)

(1,0,1)

(0,2,0)

Sample Input 2

13 1 4 3000

Sample Output 2

87058



Sample input:
1 2 3 4


Sample output:
4

Submission status: Time Limit Exceeded

Solution code:
r,g,b,n = map(int,input().split())
nr = 0
counter = 0
while nr*r <= n:
    ng = 0
    while nr*r + ng*g <= n:
        if (n-nr*r-ng*g)%b == 0:
            counter += 1
        ng += 1
    nr += 1
print(counter)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import deque
sys.setrecursionlimit(10*5)

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

print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
n_r = 0
while n_r * r <= n:
	n_g = 0
	while n_g * g + n_r * r <= n:
		if (n - r * n_r - g * n_g) % b == 0:
			ans += 1
		n_g += 1
	n_r += 1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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(i,j,N-i-j)
print(r)

Submission status: Time Limit Exceeded

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: Time Limit Exceeded

Solution code:
R,G,B,N=list(map(int,input().strip().split(' ')))
R,G,B=sorted([R,G,B])[::-1]
dic={}
count=0
for i in range(0,N//(R)+1):
    temp=i*R
    for j in range(0,(N-temp)//G+1):
        temp2=j*G
        if (temp+temp2)<N+1 and (N-temp-temp2)%B==0:
            count+=1
print(count)

Submission status: Time Limit Exceeded

Solution code:
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
r,g,b,n=IL()
ans=0
for i in range(0,n+1):
    for j in range(0,n+1):
        if (n-i*r-j*g)%b==0 and n-i*r-j*g>=0:
            ans+=1
            
print(ans)

Submission status: Time Limit Exceeded

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

sum=0
for x in range(0,3001):
    for y in range(0,3001):
        if r*x+g*y<=n and (n-r*x-g*y)%b==0:
            sum+=1
print(sum)

Submission status: Time Limit Exceeded

Solution code:
R,G,B,N=map(int,input().split())
#xR+yG+zB=Nの自然数解の個数
ans=0
for x in range(int(N/R)+1):
    for y in range(int(N/G)+1):
        nokori=N-x*R-y*G
        if nokori>=0 and nokori%B==0:
            ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [R, G, B, N] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2]), int(input_raw[3])]
    count = 0
    for x in range(N + 1):
        for y in range(N + 1):
            z = (N - x * R - y * G)/B
            if (x * R + y * G + z * B) == N and x >= 0 and y >= 0 and z>= 0:
                count += 1
    print count

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(3001):
	for j in range(3001):
		rest = n - a*i - b*j
		if rest >= 0 and rest % c == 0:
			ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    r, g, b, n = get_li()
    ans = 0
    for x in range(n // r + 1):
        for y in range(n // g + 1):
            z = n - r * x - g * y
            if z % b != 0 or z < 0:
                continue
            ans += 1
    print(ans)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

R,G,B,N = inpl()
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
from typing import List


class Solution:
    def numSubarrayProductLessThanK(self, nums: List[int], k: int) -> int:
        left = 0
        ans, prod = 0, 1
        lenght = 0
        for num in nums:
            if prod * num >= k:
                prod *= num
                lenght += 1
                while prod >= k:
                    prod //= nums[left]
                    left += 1
                    lenght -= 1
                ans += lenght
            else:
                prod *= num
                lenght += 1
                ans += lenght
            # print(ans)

        return ans



def main() -> None:
    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 % b != 0:
                continue
            # k //= b

            if i + j + k == n and k >= 0:
                cnt += 1
            # print(i, j, k )

    print(cnt)



# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self, **kwargs):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = 0
for r in range(0, N+1, 1):
    for g in range(0, N+1 - R*r, 1):
        if N - R*r - G*g < 0:
            continue
        elif (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+1):
    for g in range(n+1):
        bb = n - r*R - g*G
        if bb < 0:
            break
        elif bb%B == 0:
            cnt += 1
print(cnt)

Submission status: Accepted

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

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

print(cnt)

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//g+1):
        if (n-(r*i + g*j))%b == 0 and (n-(r*i + g*j))//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):
    nR = N-r*R
    for g in range(0,nR//G+1):
        nG = nR-g*G
        if nG%B==0:
            cnt += 1
print(cnt)

Submission status: Accepted

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

answer = 0
for r in range(N//R+1):
  for g in range(N//G+1):
    if r*R + g*G > N:
      break
    elif (N-r*R-g*G)%B != 0:
      continue
    else:
      answer += 1
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

A = [R,G,B]

count=0
for i in range(N+1):
  for j in range(N+1):
    if N-i*A[0]-j*A[1]<0:
      break
    elif (N-i*A[0]-j*A[1])%A[2]==0:
      count+=1

print(count)

Submission status: Accepted

Solution code:
colorn = list(map(int, input().split()))
color = colorn[0:3]
n = colorn[-1]
color.sort()

a, b, c = color[2], color[1], color[0]

a_max = n // a
cnt = 0
ip, jp, kp = -1, -1, -1

for i in range(a_max + 1):
    b_max = (n - a * i) // b
    d = n - a * i
    flag = 0
    for j in range(b_max + 1):
        c_max = (n - a * i - b * j) // c
        for k in range(c_max, c_max + 2):
            if a * i + b * j + c * k == n:
                cnt += 1
                if ip == i:
                    dj = j - jp
                    cnt += ((d // b - j) // dj)
                    flag = 1
                    break
                else:
                    ip, jp, kp = i, j, k
            elif a * i + b * j + c * k > n:
                break
        if flag == 1:
            break
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import copy
import math
import itertools
import numpy as np
import re

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

cnt=0
for i in range(0,m+1,r):
  for j in range(0,m+1,g):
      if i+j > m:
        break
      elif (m-(i+j))%b==0:
        cnt+=1
      
print(cnt)

Submission status: Accepted

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

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

main()

Submission status: Accepted

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

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

main()

Submission status: Accepted

Solution code:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

R,G,B,N = mint()
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 and tmp%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(0, n+1, r):
    for j in range(0, n+1, g):
        if n < (i+j):
            break
        elif (n-(i+j))%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):
  for g in range((n//G)+1):
    
      if (n - (r*R + g*G)) % B == 0 and n - (r*R + g*G) >= 0:
        
        cnt +=1
print(cnt)

Submission status: Accepted

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

li=[R,G,B]
ans=0
li.sort(reverse=True)


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# diverta 2019 Programming Contest: B – RGB Boxes
R, G, B, N = [int(i) for i in input().split()]

bingo = 0

for r in range(N + 1):
    if R * r > N:
        break
    for g in range(N + 1):
        b = (N - (R * r + G * g)) // B
        if b < 0:
            break
        elif R * r + G * g + B * b == N:
            bingo += 1

print(bingo)

Submission status: Accepted

Solution code:
# diverta 2019 Programming Contest: B – RGB Boxes
R, G, B, N = [int(i) for i in input().split()]

bingo = 0

for r in range(0, 3001):
    if R * r > N:
        break
    else:
        for g in range(0, 3001):
            b = (N -(R * r + G * g)) // B
            if b < 0:
                break
            elif R * r + G * g + B * b == N:
                bingo += 1

print(bingo)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    ans = 0
    f = False
    for i in range(N + 1):
        if i * R > N:
            break
        for j in range(N + 1):
            if i * R + j * G > N:
                break

            if (N - (i * R + j * G)) % B == 0:
                ans += 1

    print(ans)



if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
r,g,b,n = map(int, raw_input().split())
mem = {}
def dfs(i, ais, tot):
	if tot < 0:
		return 0
	if i == len(ais):
		return 1 if tot == 0 else 0
	if i == len(ais) -1:
		return 1 if (tot >= 0 and tot % ais[i] == 0) else 0
	key = (i,tot)
	if key in mem:
		return mem[(i,tot)]
	nt = tot
	cumul = 0
	cumul += dfs(i + 1, ais, tot)
	while(tot>0):
		tot -= ais[i]
		cumul += dfs(i+1, ais, tot)
	mem[key] = cumul
	return cumul


print dfs(0,[r,g,b],n)

Submission status: Accepted

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

ans = 0

for i in range(N + 1):
    r = R * i
    if r > N:
        break
    for j in range(N + 1):
        g = G * j
        if r + g > N:
            break
        b = N - r - g
        if b % B == 0:
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    rbl,gbl,bbl,n = LI()
    rmx = n//rbl
    ans = 0
    
    for r in range(rmx+1):
        gmx = (n-rbl*r)//gbl
        for g in range(gmx+1):
            reminder = n - (rbl*r+gbl*g)
            if reminder%bbl == 0:
                ans += 1
    
    print(ans)
main()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
R, G, B, N = map(int, input().split())
ans = 0
i = 0
while R*i <=  N:
    j = 0
    while R*i + G*j <=  N:
        if (N - R*i - G*j) % B ==  0:
            ans += 1
        j += 1
    i += 1
print(ans)

Submission status: Accepted

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

r,g,b,n = I()
a = []
a.append(r)
a.append(g)
a.append(b)
a.sort()
a[0],a[1],a[2] = r,g,b

mx_b = n//b
amari = n%b
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:
R, G, B, N = map(int, input().split())
ans = 0
Rmax=N//R
Gmax=N//G
for i in range(Rmax+1):
    for j in range(Gmax+1):
        total=i*R+j*G
        if N-total<0:
            break
        elif (N-total)%B==0:
            ans+=1
    if j==0:
        break
print(ans)

Submission status: Accepted

Solution code:
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化

def main():
    RGB = list(map(int,input().split()))
    N = RGB.pop()
    #print(N)
    RGB.sort(reverse=True)
    ans = 0
    for i in range(N//RGB[0]):
        N_1 = N % RGB[0] + RGB[0] * i
        #print(N_1)
        for j in range(N_1//RGB[1]):
            N_2 = N_1 % RGB[1] + RGB[1] * j
            if N_2 % RGB[2] == 0:
                ans += 1
        if N_1 % RGB[2] == 0:
                ans += 1
    for j in range(N//RGB[1]):
            N_1 = N % RGB[1] + RGB[1] * j
            if N_1 % RGB[2] == 0:
                ans += 1
    if N % RGB[2] == 0:
                ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

R, G, B, N = mapint()

ans = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        rg = r*R + g*G
        if rg>N:
            continue
        if (N-rg)%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(n//r + 1):
    for j in range(n//g + 1):
        if (n - (r*i + g*j)) % b == 0 and n - (r*i + g*j) >= 0:
            count += 1
print(count)

Submission status: Accepted

Solution code:
from statistics import median

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

count = 0
for r in range(N+1):
    for g in range(N+1):
        if (N - R*r - G*g) < 0:
            break
        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())
ans = 0
for i in range(N//R+1):
  for j in range(N//G+1):
    nokori = N-i*R-j*G
    if nokori >=0 and nokori%B == 0:
      ans +=1
      #print(i,j,nokori//B)
print(ans)

Submission status: Accepted

Solution code:
*s,n=map(int,input().split())
s.sort()
c=0
for i in range(n//s[2]+1):
    for j in range(n//s[1]+1):
        if (n-s[2]*i-s[1]*j)%s[0] == 0 and 0<=(n-s[2]*i-s[1]*j):
            #print(i,j,n-s[2]*i-s[1]*j)
            c+=1
print(c)

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):
        b = (N-R*r-G*g)
        if b >= 0 and b%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(1+N//R):
    for g in range(1+N//G):
        #print(N-(r*R+g*G),r*R, g*G)
        if N-(r*R+g*G) < 0:
            break
        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 + 1):
    total = i * r
    if total > n:
        break
    for j in range(n + 1):
        total2 = total + j * g
        if total2 > n:
            break
        b_cnt = n - total2
        if b_cnt % 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 + 1):
    if i * r > n:
        break
    for j in range(n + 1):
        if i * r + j * g > n:
            break
        bnum = n - i * r - j * g
        if bnum % b == 0:
            ans += 1
print(ans)

Submission status: Accepted

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


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

    for i in range(3000 + 1):
        for j in range(3000 + 1):
            diff = n - (r * i + g * j)

            if diff >= 0 and (diff % b == 0):
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from itertools import product


def read():
    R, G, B, N = map(int, input().strip().split())
    return R, G, B, N


def solve(R, G, B, N):
    ans = 0
    for r, g in product(range(3001), range(3001)):
        v = N - R * r - G * g
        b = v // B
        if v >= 0 and B * b == v:
            ans += 1
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))