コード例 #1
0
        private int GetLastKindAmount(Pair coinsTypes)
        {
            if (coinsTypes.Next == null)
            {
                return coinsTypes.Value;
            }

            return GetLastKindAmount(coinsTypes.Next);
        }
コード例 #2
0
        private int Calculate(int total, Pair coinsTypes)
        {
            if (total == 0)
            {
                return 1;
            }

            if (total < 0)
            {
                return 0;
            }

            if (coinsTypes == null)
            {
                return 0;
            }

            return Calculate(total - GetLastKindAmount(coinsTypes), coinsTypes)
                + Calculate(total, Pair.RemoveLast(coinsTypes));
        }