Problem:


Score : 200 points

Problem Statement

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

Red boxes, each containing R red balls

Green boxes, each containing G green balls

Blue boxes, each containing B blue balls

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

Constraints

All values in input are integers.

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

Input

Input is given from Standard Input in the following format:

R G B N

Output

Print the answer.

Sample Input 1

1 2 3 4

Sample Output 1

4

Four triples achieve the objective, as follows:

(4,0,0)

(2,1,0)

(1,0,1)

(0,2,0)

Sample Input 2

13 1 4 3000

Sample Output 2

87058



Sample input:
1 2 3 4


Sample output:
4

Submission status: Wrong Answer

Solution code:
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 or N-r*R-g*G > B or (N-r*R-g*G)%B == 0:
      continue
    else:
      answer += 1
print(answer)

Submission status: Wrong Answer

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

answer = 0
for r in range(R+1):
  for g in range(G+1):
    if r + g > N or N - r - g > B:
      continue
    else:
      answer += 1
print(answer)

Submission status: Wrong Answer

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

answer = 0
for r in range(R):
  for g in range(G):
    if r + g > N or N - r - g > B:
      continue
    else:
      answer += 1
print(answer)

Submission status: Wrong Answer

Solution code:
import math

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

a, b, c = color[2], color[1], color[0]
g = math.gcd(b, c)

a_max = n // a
b_max = n // b
c_max = n // c
cnt = 0

if n % math.gcd(a, g) != 0:
    print(cnt)
else:
    for i in range(a_max + 1)[::-1]:
        if (n - a * i) % g != 0:
            break
        b_max = (n - a * i) // b
        for j in range(b_max + 1)[::-1]:
            c_max = (n - a * i - b * j) // c
            for k in range(c_max + 1)[::-1]:
                if a * i + b * j + c * k == n:
                    cnt += 1
                elif a * i + b * j + c * k < n:
                    break     
    print(cnt)

Submission status: Wrong Answer

Solution code:
import math

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

a, b, c = color[2], color[1], color[0]
g = math.gcd(b, c)

a_max = n // a
b_max = n // b
c_max = n // c
cnt = 0

for i in range(a_max + 1)[::-1]:
    if (n - a * i) % g != 0:
        break
    b_max = (n - a * i) // b
    for j in range(b_max + 1)[::-1]:
        c_max = (n - a * i - b * j) // c
        for k in range(c_max + 1)[::-1]:
            if a * i + b * j + c * k == n:
                cnt += 1
            elif a * i + b * j + c * k < n:
                break     
print(cnt)

Submission status: Wrong Answer

Solution code:
import math

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

a, b, c = color[2], color[1], color[0]
g = math.gcd(b, c)

a_max = n // a
b_max = n // b
c_max = n // c
cnt = 0

for i in range(a_max + 1)[::-1]:
    if (n - a * i) % g == 0:
        break
    b_max = (n - a * i) // b
    for j in range(b_max + 1)[::-1]:
        c_max = (n - a * i - b * j) // c
        for k in range(c_max + 1)[::-1]:
            if a * i + b * j + c * k == n:
                cnt += 1
            elif a * i + b * j + c * k < n:
                break     
print(cnt)

Submission status: Wrong Answer

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))%b == 0:
            ans += 1
        elif n < (i+j):
            break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def combination(a,b,n):
    if a+b<n:
        return 0
    elif a+b==n:
        return 1
    elif n==0:
        return 0
    elif a>=n and b>=n:
        return n+1
    elif a>=n and b<n:
        return b
    elif a<n and b>=n:
        return a
    else:
        return a+b-n+1



R,G,B,N=map(int,input().split())
ans=0
total=R+G+B


if total<N:
    print(0)
    exit()
else:
    temp=[R,G,B]
    temp.sort()
    nin=temp[0]
    for i in range(nin+1):
        n=N-i
        ans+=combination(temp[2],temp[1],n)
        if n==0:
            ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
def combination(a,b,n):
    if a+b<n:
        return 1
    elif a>=n and b>=n:
        return n+1
    elif a>=n and b<n:
        return b
    elif a<n and b>=n:
        return a
    else:
        return n-max(a,b)+1


R,G,B,N=map(int,input().split())
ans=0
total=R+G+B


if total<N:
    print(0)
    exit()
else:
    temp=[R,G,B]
    temp.sort()
    nin=temp[2]
    for i in range(nin+1):
        n=N-i
        ans+=combination(temp[0],temp[1],n)

print(ans)

Submission status: Wrong Answer

Solution code:

def combination(a,b,n):
    if a+b<n:
        return 1
    elif a>=n and b>=n:
        return n
    elif a>=n and b<n:
        return b
    elif a<n and b>=n:
        return a
    else:
        return n-max(a,b)+1


R,G,B,N=map(int,input().split())
ans=0
total=R+G+B


if total<N:
    print(0)
    exit()
else:
    temp=[R,G,B]
    temp.sort()
    nin=temp[2]
    for i in range(nin):
        n=N-i
        ans+=combination(temp[0],temp[1],n)

print(ans)

Submission status: Wrong Answer

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, tot) in mem:
		return mem[(i,tot)]
	
	cumul = 0
	cumul += dfs(i + 1, ais, tot)
	while(tot>0):
		tot -= ais[i]
		cumul += dfs(i+1, ais, tot)
	mem[(i,tot)] = cumul
	return cumul


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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

t = n**0.5

cnt = 0
for i in range(n-r+2):
    for j in range(n-g+2):
        for k in range(n-b+2):
            if i + j*g + b*k == n:
                cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
import collections


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for r in range(min(3000, 3000 // R) + 1):
    if R * r > N:
        for g in range(min(3000, 3000 // G) + 1):
            v = R * r + G * g
            if N >= v and (N - v) % B == 0:
                ans += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# from pprint import pprint
# import math
# import collections

# n = int(input())
R, G, B, N = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

max_r, max_g, max_b = N // R, N // G, N // B
ans = []

r, g, b = 0, 0, 0
for r in range(max_r + 1):
    if R * r > N:
        break
    for g in range(max_g + 1):
        if R * r + G * g > N:
            break
        x = (N - (R * r + G * g))
        if x % B == 0 and x >= 0:
            b = x // B
            a = (r, g, b)

            ans.append(a)
            break

print(len(ans))

Submission status: Wrong Answer

Solution code:
# from pprint import pprint
# import math
# import collections

# n = int(input())
R, G, B, N = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

max_r, max_g, max_b = N // R, N // G, N // B
ans = []

r, g, b = 0, 0, 0
for r in range(1, max_r + 1):
    for g in range(1, max_g + 1):
        if R * r + G * g > N:
            break
        x = (N - (R * r + G * g))
        if x % B == 0 and x >= 0:
            b = x // B
            a = (r, g, b)

            ans.append(a)

print(len(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

ans = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        if (N - R*r - G*g)%B == 0:
            ans += 1
        # if check >= 0 and check%B == 0:
            # ans += 1
        # if check == 0:
        #     # print(r, g, check//B, check)
        #     ans += 1
        # elif check > 0 and check%B == 0:
        #         # print(r, g, check//B, check)
        #         ans += 1

print(ans)

Submission status: Wrong Answer

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

ans = 0
for r in range(N//R+1):
    for g in range(N//G+1):
        if (N - R*r - G*g)%B == 0:
            ans += 1
        # if check >= 0 and check%B == 0:
            # ans += 1
        # if check == 0:
        #     # print(r, g, check//B, check)
        #     ans += 1
        # elif check > 0 and check%B == 0:
        #         # print(r, g, check//B, check)
        #         ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
[A,B,C,N]=[int(i) for i in input().split()]
X=[A,B,C]
X.sort()
[C,B,A]=X
cnt=0
for i in range(N//A):
  k=N-(i*A)
  for j in range(k//B):
    if (k-(B*j))%C==0:cnt+=int((k-(B*j))/C)-1
print(cnt)

Submission status: Wrong Answer

Solution code:
[A,B,C,N]=[int(i) for i in input().split()]
X=[A,B,C]
X.sort()
[C,B,A]=X
cnt=0
for i in range(N//A):
  k=N-(i*A)
  for j in range(k//B):
    if (k-(B*j))%C==0:cnt+=(k-(B*j))/C
print(cnt)

Submission status: Wrong Answer

Solution code:
[A,B,C,N]=[int(i) for i in input().split()]
X=[A,B,C]
X.sort()
[C,B,A]=X
cnt=0
for i in range(N//A):
  k=N-(i*A)
  for j in range(k//B):
    if (k-(B*A))%C==0:cnt+=(k-(B*A))/C
print(cnt)

Submission status: Wrong Answer

Solution code:
[A,B,C,N]=[int(i) for i in input().split()]
X=[A,B,C]
X.sort()
[C,B,A]=X
cnt=0
for i in range(N//A):
  k=N-(i*A)
  for j in range(k//B):
    if (k-(B*A))%C==0:cnt+=1
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


R, G, B = sorted((R, G, B), reverse=True)

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

ans

Submission status: Wrong Answer

Solution code:
R,G,B,N = map(int, input().split())
index = 0
ans = 0
for_sort = [R,G,B]
for_sort.sort()
r = for_sort[2]
g = for_sort[1]
b = for_sort[0]
while N >=0:
  mid = N
  N -= r
  while mid >= 0:
    mid -= g
    if mid % b == 0:
      ans += 1
      
print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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 (n-R*r+G*g)/B <= n//B:
                count+=1
                break
print(count)

Submission status: Wrong Answer

Solution code:
#diverta2019 programming contest-B
R,G,B,n = map(int,input().split())
cnt = 0
for i in range(n//R):
    for j in range(n//G):
        for k in range(n//B):
            if i*R + j*G + k*B == n:
                cnt += 1
                
print(cnt)

Submission status: Wrong Answer

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(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
#from decimal import *

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections

def useOne(a, b, c, n):
    count = 0
    if n%a == 0: count += 1
    if n%b == 0: count += 1
    if n%c == 0: count += 1
    return count

def useTwo(a, b, n):
    a, b = sorted([a, b])
    count = 0
    maxCountOfA = n//a
    maxCountOfB = n//b
    
    startCount = 1
    for i in range(maxCountOfA, 0, -1):
        for j in range(startCount, maxCountOfB+1):
            _sum = i*a + j*b
            if _sum == n:
                count += 1
                startCount = j+1
                break
            if _sum > n:
                startCount = j
                break
    return count

def useThree(a, b, c, n):
    a, b, c = sorted([a, b, c])
    maxCountOfA = n//a
    maxCountOfB = n//b
    maxCountOfC = n//c
    count = 0
    for i in range(1, maxCountOfA+1):
        startCountOfC = maxCountOfC
        for j in range(1, maxCountOfB+1):
            _sum = i*a + j*b
            if _sum >= n:
                maxCountOfB = j
                break
            for k in range(startCountOfC, 0, -1):
                _sum = i*a + j*b + k*c
                if _sum == n:
                    count += 1
                    startCountOfC = k-1
                    break
                if _sum < n:
                    startCountOfC = k
                    break
    return count

def answer(a, b, c, n):
    # useTwo(a, b, n)
    count = useOne(a, b, c, n)
    count += useTwo(a, b, n)
    count += useTwo(a, c, n)
    count += useTwo(b, c, n)
    print("two count...")
    count += useThree(a, b, c, n)
    return count
    
a, b, c, n = map(int, input().split())
print(answer(a, b, c, n))

Submission status: Wrong Answer

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

lst = [R, G, B]
lst.sort()
k2, k1, k0 = lst

ans = 0
if lst != [1, 1, 1]:
    for n0 in range(N//k0 + 1):
        for n1 in range(N//k1 + 1):
            nn = (N - n0 * k0 - n1 * k1)
            if nn >= 0 and nn % k2 == 0: ans += 1
    print(ans)
else: print(4504501)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Solution code:
R, G, B, N = 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: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
for i in range(3001):
    for j in range(3001):
        b = (N-i*R-j*G)/B
        if b.is_integer() and b >= 0:
            ans += 1
            print(i, j, b)
        if b < 0:
            break

print(ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(n):
    for j in range(n):
        if i * r + j * g > n:
            break
        k = n - (i * r + j * g)

        if k % b == 0:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
r,g,b,n = map(int,input().split())
ls = [r,g,b]
z = ls[0]
y = ls[1]
x = ls[2]
ls.sort()
p = n
q = 0
X = n//x +1
Y = n//y +1
Z = n//z +1
for i in range(X):
    p = n
    for j in range(Y):
        p = n -i*x
        if p >= j*y:
            continue
        else:
            break
        for k in range(Z):
            p = n -i*x -j*y
            if p == k*z:
                q += 1
print(q)

Submission status: Wrong Answer

Solution code:
import math

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
R, G, B, N = map(int, input().split())
"""
3000以下なので全探索を考える
まず，全探索できるものは全探索を考える
"""

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 標準入力の取得
R, G, B, N = list(map(int, input().split()))

# 求解処理
r_max = N // R
g_max = N // G
b_max = N // B
rgb_max = [r_max, g_max, b_max]
rgb_max = sorted(rgb_max)
rgb_max_ball_num = {r_max: R, g_max: G, b_max: B}
result = 0
rgb_max0 = rgb_max[0]
rgb_max1 = rgb_max[1]
rgb_max2 = rgb_max[2]
for i in range(rgb_max0 + 1):
    n_i = i * rgb_max_ball_num[rgb_max0]
    for j in range(rgb_max1 + 1):
        n_ij = n_i + j*rgb_max_ball_num[rgb_max1]
        if N < n_ij:
            continue
        if (N - n_ij) % rgb_max_ball_num[rgb_max2] == 0:
            result += 1

# 結果出力
print(result)

Submission status: Wrong Answer

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

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

First = Largest[2]
Second = Largest[1]
Last = Largest[0]

Many = math.floor(N/First)
Money = math.floor(N/Second)

count=0

for i in range (0, Many+1):
	for j in range (0, Money+1):
		if i*First+j*Second <= N and (N-i*First+j*Second)%Last ==0:
			count+=1

print(count)

Submission status: Wrong Answer

Solution code:
n=list(map(int,input().split()))
maiden=0;z=0
if(n[0]==1 and n[1]==1 and n[2]==1):
    print(4504501)
else:
    for i in range((n[3]//n[0])+1):
        for j in range((n[3]//n[1])+1):
            z=(n[3]-i*n[0]-j*n[1])/n[2]
            if(z%1==0 and z>=0):
                maiden=maiden+1    
    print(maiden)

Submission status: Wrong Answer

Solution code:
n=list(map(int,input().split()))
aaa = sorted(n,reverse=True)
maiden=0;z=0
for i in range(int(n[3]/aaa[1])+1):
    for j in range(int(n[3]/aaa[2])+1):
        z=(n[3]-i*aaa[1]-j*aaa[2])/aaa[3]
        valor = i*aaa[1]+j*aaa[2]+z*aaa[3]
        if(z%1==0 and z>=0):
            valor = i*aaa[1]+j*aaa[2]+z*aaa[3]
            if(valor==n[3]):
                maiden=maiden+1    
print(maiden)

Submission status: Wrong Answer

Solution code:
n=list(map(int,input().split()))
aaa = sorted(n,reverse=True)
maiden=0;z=0
for i in range(int(n[3]/aaa[1])+aaa[1]):
    for j in range(int(n[3]/aaa[2])+aaa[2]):
        z=(n[3]-i*aaa[1]-j*aaa[2])/aaa[3]
        if(z%1==0 and z>=0):
            maiden=maiden+1    
print(maiden)

Submission status: Wrong Answer

Solution code:
n=list(map(int,input().split()))
aaa = sorted(n,reverse=True)
valor=0;maiden=0;z=0
for i in range(int(n[3]/aaa[1])+1):
    for j in range(int(n[3]/aaa[2])+1):
        z=(n[3]-i*aaa[1]-j*aaa[2])/aaa[3]
        if(z%1==0 and z>=0):
            maiden=maiden+1    
print(maiden)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil


def main():
    r, g, b, n = map(int, input().split())
    answer = 0
    for i in range(ceil(n / r) + 1):
        for j in range(ceil((n - i * r) / g) + 1):
            left = n - i * r - j * g
            if left % b == 0:
                answer += 1
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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):
    b=(N-r*R+g*G)//B
    if(r*R+g*G+b*B==N):
      ans+=1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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(1,r+1):
  for j in range(1,g+1):
    for k in range(1,b+1):
      if i*R+j*G+k*B==N:
        s+=1
print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

read = sys.stdin.buffer.read
# input = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a, b, c, n = map(int, input().split())
ans = 0
for i in range(3001):
    for j in range(3001):
        if n <= i * a + j * b and (n - i * a - j * b) % c == 0:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
r,g,b,n = map(int,input().split(' '))
A = [r,g,b]
A.sort()
r,g,b = A[2], A[1], A[0]
rmax, gmax = n//r, n//g
count = 0
i = 0
while i <= rmax:
    j = 0
    if g == 1:
        count += (n-i*r)
        j += 30000
    while (n-i*r-j*g) >= 0:
        if (n-i*r-j*g)%b == 0:
            count += 1
        j += 1
    i += 1
print(count)

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    R, G, B, N = map(int, input().split())
    count = 0
    for i in range(N // R + 2):
        red = R * i
        lem = N - red
        for j in range(lem // G + 2):
            green = G * j
            if (lem - green) % B == 0: count += 1
    print(count)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    R, G, B, N = map(int, input().split())
    count = 0
    for i in range((N - 1)// R + 2):
        red = R * i
        lem = N - red
        for j in range((lem - 1) // G + 2):
            green = G * j
            if (lem - green) % B == 0: count += 1
    print(count)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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