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: Runtime Error

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

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

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

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
R,G,B,N = IL()
count += 1
for r in range(N+1):
  for g in range(N+1):
    if r*R+g*G <= N and (N-(r*R+g*G))%B == 0:
      count += 1
print(count)

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(float, 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
#from decimal import *
 
R, G, B, N = MAP()
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: Runtime Error

Solution code:
cnt = 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 :
            #print(r,g,(N-r-g))
            cnt += 1

print(cnt)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
print(N*(N+1)*(2*N+1)//6)

Submission status: Runtime Error

Solution code:
N=int(input())
print(N*(N+1)*(2*n+1)//6)

Submission status: Runtime Error

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

BALL = [0]*(N+100)
BALL[0] = 1

for num in range(0,N+1,1):
    if BALL[num] != 0:
        BALL[num+R] += BALL[num]
for num in range(0,N+1,1):
    if BALL[num] != 0:
        BALL[num+G] += BALL[num]

for num in range(0,N+1,1):
    if BALL[num] != 0:
        BALL[num+B] += BALL[num]

print(BALL[N])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
R, G, B, N = map(int, input().split())
R, G, B = sorted([R, G, B], reverse=True)
maxR = N // R
ans = 0
if R == 1:
    ans += (N+2)(N+1) // 2
    print(ans)
    quit()

for r in range(maxR+1):
    if r * R == N:
        ans += 1
        continue
    n = N - r * R
    maxG = n // G
    for g in range(maxG+1):
        if g * G == n:
            ans += 1
            continue
        nn = n - g * G
        maxB = nn // B
        for b in range(maxB+1):
            if b * B == nn:
                ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
R, G, B, N = map(int, input().split())
R, G, B = sorted([R, G, B], reverse=True)
maxR = N // R
ans = 0
if R == 1:
    ans += (N+2)(N+1) // 2
    print()
    quit()

for r in range(maxR+1):
    if r * R == N:
        ans += 1
        continue
    n = N - r * R
    maxG = n // G
    for g in range(maxG+1):
        if g * G == n:
            ans += 1
            continue
        nn = n - g * G
        maxB = nn // B
        for b in range(maxB+1):
            if b * B == nn:
                ans += 1

print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

#pythonだとTLE/pypyだとAC
'''
r,g,b,n = iim()
ans = 0
for i in range(n//r+1):
    for j in range(n//g+1):
        num = n-i*r-j*g
        if num%b == 0 and num//b >= 0:
#            print(i,j,num//b)
            ans += 1
print(ans)
'''

#上を受けてpythonでも通るように改良
*num,n = iim()
a,b,c = map(int,sorted(num))
ans = 0
for i in range(n//c+1):
    if a!= 1:
        for j in range(n//b+1):
            num = n-i*r-j*g
            if num%a == 0 and num//a >= 0:
                ans += 1
    else:
        n -= i*c
        if n == 0:
            ans += 1
        elif n > 0:
            if n%b == 0:
                ans += n//b+1
            else:
                ans += n//b
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

ll lcm(ll a,ll b){
    return (a*b/gcd(a,b));
}

int main(){
    ios::sync_with_stdio(false);
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int ans=0;
    rep(i,3001){
        rep(j,3001){
            if(((n-r*i-g*j)%b==0) && (n>=r*i+g*j)){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Submission status: Runtime Error

Solution code:
def main():
  r, g, b, n = input_list()
  ans = 0
  for x in range(n//r+1):
    for y in range(n//g+1):
      rr = r*x
      gg = g*y
      if rr + gg > n:
        continue
      bb = (n - rr - gg)
      if bb % b != 0:
        continue
      ans += 1
  print(ans)
main()

Submission status: Runtime Error

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

RL=(N+R-1)//R
if RL*F>N:
    RL=RL-1

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

print(cnt)

Submission status: Runtime Error

Solution code:
import sys
r, g, b, n = [int(i) for i in sys.stdin.readline().split()]
memo_ls = [[0 for j in range(n+1)] for i in range(4)]
memo_ls[0][0] = 1
for i, color in enumerate([r, g, b], 1):
    for j in range(n + 1):
        memo_ls[i][j] = memo_ls[i-1][j] + memo_ls[i][j-color]
print(memo_ls[-1][-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#import sys

#入力受け取り
R = int(input())
G = int(input())
B = int(input())
N = int(input())

#計算用
r_num = R
#条件を満たす通り
result = 0

#Rが絡むパターンを確認
while True:
    #r_numとNが等しかったらループを抜ける
    if r_num == N:
        result = result + 1
        break
    #r_numがNを上回ったらループを抜ける
    elif r_num > N:
        break
    #r_numとg_numの組み合わせを確認
    g_num = G
    while True:
        #r_numとg_numの組み合わせが等しかったらループを抜ける
        rg_num = r_num + g_num
        if rg_num == N:
            result = result + 1
            break
        #r_numとg_numの組み合わせがNを上回ったらループを抜ける
        elif rg_num > N:
            break
        #r_numとg_numとb_numの組み合わせを確認
        b_num = B
        while True:
            #r_numとg_numとb_numの組み合わせが等しかったらループを抜ける
            rgb_num = r_num + g_num + b_num
            if rgb_num == N:
                result = result + 1
                break
            #r_numとg_numとb_numの組み合わせがNを上回ったらループを抜ける
            elif rgb_num > N:
                break
            #b_numを増やす
            b_num = b_num + B
        #g_numをG増やす
        g_num = g_num + G
    #r_numとb_numの組み合わせを確認
    b_num = B
    while True:
        #r_numとb_numの組み合わせが等しかったらループを抜ける
        rb_num = r_num + b_num
        if rb_num == N:
            result = result + 1
            break
        #r_numとb_numの組み合わせがNを上回ったらループを抜ける
        elif rb_num > N:
            break
        #b_numを増やす
        b_num = b_num + B
    #r_numを増やす
    r_num = r_num + R

#Rが絡まずGが絡むパターンを確認
g_num = G
while True:
    #g_numとNが等しかったらループを抜ける
    if g_num == N:
        result = result + 1
        break
    #g_numがNを上回ったらループを抜ける
    elif g_num > N:
        break
    #g_numとb_numの組み合わせを確認
    b_num = B
    while True:
        #g_numとb_numの組み合わせが等しかったらループを抜ける
        gb_num = g_num + b_num
        if gb_num == N:
            result = result + 1
            break
        #g_numとb_numの組み合わせがNを上回ったらループを抜ける
        elif gb_num > N:
            break
        #b_numを増やす
        b_num = b_num + B
    #g_numを増やす
    g_num = g_num + G

#Bのみが絡むパターンを確認
b_num = B
while True:
    #b_numとNが等しかったらループを抜ける
    if b_num == N:
        result = result + 1
        break
    #b_numがNを上回ったらループを抜ける
    elif b_num > N:
        break
    #b_numを増やす
    b_num = b_num + B

#resultを返却
print(result)

Submission status: Runtime Error

Solution code:
import sys

#入力受け取り
R = input()
G = input()
B = input()
N = input()

#計算用
r_num = R

#条件を満たす通り
result = 0

#Rが絡むパターンを確認
while(1):
	#r_numとNが等しかったらループを抜ける
	if r_num == N:
 		result = result + 1
      	break
    #r_numがNを上回ったらループを抜ける
    elif r_num > N:
      	break
    
    #r_numとg_numの組み合わせを確認
    g_num = G
    while(1):
      	#r_numとg_numの組み合わせが等しかったらループを抜ける
     	rg_num = r_num + g_num
        if rg_num == N:
        	result = result + 1
            break
        #r_numとg_numの組み合わせがNを上回ったらループを抜ける
        elif rg_num > N:
          	break
        
        #r_numとg_numとb_numの組み合わせを確認
        b_num = B
        while(1):
          	#r_numとg_numとb_numの組み合わせが等しかったらループを抜ける
            rgb_num = r_num + g_num + b_num
            if rgb_num == N:
            	result = result + 1
              	break
           	#r_numとg_numとb_numの組み合わせがNを上回ったらループを抜ける
            elif rgb_num > N:
              	break
            #b_numを増やす
            b_num = b_num + B        
        #g_numをG増やす
        g_num = g_num + G
    
    #r_numとb_numの組み合わせを確認
    b_num = B
    while(1):
      	#r_numとb_numの組み合わせが等しかったらループを抜ける
        rb_num = r_num + b_num
        if rb_num == N:
        	result = result + 1
          	break
        #r_numとb_numの組み合わせがNを上回ったらループを抜ける
        elif rb_num > N:
          	break
        #b_numを増やす
        b_num = b_num + B
	#r_numを増やす
    r_num = r_num + R

#Rが絡まずGが絡むパターンを確認
g_num = G
while(1):
	#g_numとNが等しかったらループを抜ける
	if g_num == N:
 		result = result + 1
      	break
    #g_numがNを上回ったらループを抜ける
    elif g_num > N:
      	break
    #g_numとb_numの組み合わせを確認
    b_num = B
    while(1):
      	#g_numとb_numの組み合わせが等しかったらループを抜ける
        gb_num = g_num + b_num
        if gb_num == N:
        	result = result + 1
          	break
        #g_numとb_numの組み合わせがNを上回ったらループを抜ける
        elif gb_num > N:
          	break
        #b_numを増やす
        b_num = b_num + B
	#g_numを増やす
    g_num = g_num + G

#Bのみが絡むパターンを確認
b_num = B
while(1):
	#b_numとNが等しかったらループを抜ける
	if b_num == N:
 		result = result + 1
      	break
    #b_numがNを上回ったらループを抜ける
    elif b_num > N:
      	break
	#b_numを増やす
    b_num = b_num + B

#resultを返却
return result

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans = 0
for b in range(N+1):
    for g in range((N+1):
        if N-B*b-G*g >= 0 and (N-B*b-G*g)%R == 0:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import itertools
r,g,b,n=map(int,input().split())
x,y=n//r,n//g
x,y=list(range(0,r*x+1,r)),list(range(0,g*y+1,g))
l=[i+j for i,j in ()itertools.product(x,y) if i+j<n]
print(l)

Submission status: Runtime Error

Solution code:
def main():
    R,G,B,N=map(int,input().split())
    cnt=0
    for i in range(N//R+1):
        cnt+=sum([1 for j in range((N-i*R)//G+1) if i*R + j*G +((N-p-j*G)//B)*B==N])
    print(cnt)

main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for a in range(n+1):
  for c in range(n+1):
    Bb = N - r*a - g*c
    if Bb > N:
      if Bb % 2 == 0:
        count += 1
    else:
      break

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

#R*r+G*g+B*b==n
ir= int(R/N)
ig=int(G/N)
ib=int(B/N)
s=0
for R in range(ir):
    for G in range(ig):
        if(R*r+G*g>N):
            break;
        if((N-R*r-G*g)%B==0):
            s+=1
print(s)

Submission status: Runtime Error

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)


"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
r,g,b,n= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
s = 0
for i in range(n//r+1):
    for k in range(n//g+1):
        left = n-(r*i+k*g)
        if left%b == 0 and left>=0:s+=1
print(s)

Submission status: Runtime Error

Solution code:
#n = int(input())
#m = int(input())
#k = int(input())
#n, m = map(int, input().split())
r, g, b, n = map(int, input().split())
#a = list(map(int, input().split()))
#table = []
'''
for i in range h:
    temp = list(map(int, input().split()))
    table.append(temp)
'''
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: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

cnt = 0
for x in itertools.product([i for i in range(int(n/sorted_rgb[0])+1)],[j for j in range(int(n/sorted_rgb[1])+1)]):
    if ((n-x[0]*sorted_rgb[0]-x[1]*sorted_rgb[1])%sorted_rgb[2] == 0)&((n-x[0]*sorted_rgb[0]-x[1]*sorted_rgb[1])>=0):
        cnt +=1
print(cnt)

Submission status: Runtime Error

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

cnt = 0
for x in itertools.product([i for i in range(int(n/sorted_rgb[0])+1)],[j for j in range(int(n/sorted_rgb[1])+1)]):
    if ((n-x[0]*sorted_rgb[0]-x[1]*sorted_rgb[1])%sorted_rgb[2] == 0)&((n-x[0]*sorted_rgb[0]-x[1]*sorted_rgb[1])>=0):
        cnt +=1

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from sys import exit

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

count = 0

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

print(count)

Submission status: Runtime Error

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 - rR - gG) % B == 0:
      ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
r, g, b, n = map(int, raw_input().split())
count = 0
for i in xrange(3000):
	if i*r > n:
    	break
	for j in xrange(3000):
    	if i*r + j*g > n:
      		break
		if (n-i*r - j*g)% b == 0:
      		count += 1
print count

Submission status: Runtime Error

Solution code:
r, g, b, n = map(int, raw_input().split())
count = 0
for i in xrange(3000):
  if i*r > n:
    break
  for j in xrange(3000):
    if i*r + j*g > n:
      break
	if (n-i*r - j*g)% b == 0:
      count += 1
print count

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# A = list(map(int, read().split()))
n = A[-1]
A = A[:3]
A.sort(reverse=True) # descending
ans = 0
if A[1] == A[2] and A[1] == 1: #deal with 1 1
    for i in range(n+1):
        tmp = i*A[0]
        if tmp > n:break
#         print(ans, i, A)
        ans += (n-tmp) - 0 + 1
else :
    for i in range(n+1):
        for j in range(n+1):
            tmp = i * A[0] + j * A[1]
            if tmp > n:break
            tmp = n - tmp
            if tmp % A[2] == 0:
    #             print(i, j, tmp//A[2])
                ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
# read = input
A = list(map(int, read().split()))
n = A[-1]
A = A[:3]
A.sort(reverse=True) # descending
ans = 0
if A[1] == A[2]:# deal with 1 1
    for i in range(n+1):
        tmp = i*A[0]
        if tmp > n:break
        ans += (n-tmp) - 0 + 1
else :
    for i in range(n+1):
        for j in range(n+1):
            tmp = i * A[0] + j * A[1]
            if tmp > n:break
            tmp = n - tmp
            if tmp % A[2] == 0:
    #             print(i, j, tmp//A[2])
                ans += 1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

Solution code:
R,G,B,M = map(int,input().split())
cnt = 0
for r in range(3001):
  for g in range(r):
    for b in range(g):
      if N = r * R + g * G +b * B:
        cnt += 1
      else:
        continue
print(cnt)

Submission status: Runtime Error

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

ans = 0
count = N // min(R, G, B) + 1
for r in range(count):
    if r * R > N:
        break
    for g in range(count):
        if r * R + g * G > N:
            break
        for b in range(count):
            if r * R + g * G + b * B == N:
                ans += 1
                break

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans=[]

count=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)%13B==0:
            count+=1
            #ans.append([r,g,(N-r*R-g*G)/B])

#print(ans)
print(count)

Submission status: Runtime Error

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

ans=[]

count=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)%13B==0:
            count+=1
            #ans.append([r,g,(N-r*R-g*G)/B])

#print(ans)
print(count)

Submission status: Runtime Error

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

ans=[]

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

print(len(ans))

Submission status: Runtime Error

Solution code:
13 1 4 3000