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

Solution in C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Linq;

class AtCoder
{
    static void Main(string[] args)
    {
        string[] a = Input().Split(' ');
        int R = Int(a[0]);
        int G = Int(a[1]);
        int B = Int(a[2]);
        int N = Int(a[3]);
        int ans = 0;

        for(int r_i = 0;r_i * R <= N;r_i++)
        {
            for (int g_i = 0; r_i * R + g_i * G <= N; g_i++)
            {

                if((N - (r_i * R + g_i * G) )% B == 0)
                {
                    ans += 1;
                }
            }
        }

        Print(ans.ToString());
    }


    static long Gcd(long a, long b)
    {
        return (a < b) ? Gcd(b, a)
             : (b > 0) ? Gcd(b, a % b)
                       : a;
    }

    static long Lcm(long a, long b)
    {
        return a / Gcd(a, b) * b;
    }

    static int Int(string s)
    {
        return int.Parse(s);
    }

    static string String(int i)
    {
        return i.ToString();
    }

    static void Print(string text)
    {
        Console.WriteLine(text);
    }

    static string Input()
    {
        return (Console.ReadLine());
    }
}

public class Modulo
{
    private const int M = 1000000007;
    private readonly int[] m_facs;
    public int Mul(int a, int b)
    {
        return (int)(Math.BigMul(a, b) % M);
    }
    public Modulo(int n)
    {
        m_facs = new int[n + 1];
        m_facs[0] = 1;
        for (int i = 1; i <= n; ++i)
        {
            m_facs[i] = Mul(m_facs[i - 1], i);
        }
    }
    public int Fac(int n)
    {
        return m_facs[n];
    }
    public int Pow(int a, int m)
    {
        switch (m)
        {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                int p1 = Pow(a, m / 2);
                int p2 = Mul(p1, p1);
                return ((m % 2) == 0) ? p2 : Mul(p2, a);
        }
    }
    public int Div(int a, int b)
    {
        return Mul(a, Pow(b, M - 2));
    }
    public int Ncr(int n, int r)
    {
        if (n < r) { return 0; }
        if (n == r) { return 1; }
        int res = Fac(n);
        res = Div(res, Fac(r));
        res = Div(res, Fac(n - r));
        return res;
    }
}