/* © MATTO MATTI 2018 http://mattomatti.com/pl/a0143 napisane przy użyciu Visual Studio Community 2015 2018-08-22 v 1.0 */ using System; namespace plcode1cs { class Program { static int liczRozwiazaniaUnikalne(int n, int k, int x) { if (n == 1) return (x >= 1 && x <= k) ? 1 : 0; else if (x < 0 || x < n || x > k * n) return 0; int ile = 0; for (int i = Math.Min(x, k); i >= 1; i--) ile += liczRozwiazaniaUnikalne(n - 1, i, x - i); return ile; } static void Main(string[] args) { Console.Write("Ile jest kostek?\n n = "); int n = Convert.ToInt32(Console.ReadLine()); Console.Write("Ile ścian mają kostki?\n k = "); int k = Convert.ToInt32(Console.ReadLine()); Console.Write("Podaj sumę oczek\n x = "); int x = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Znaleziono: {0}", liczRozwiazaniaUnikalne(n, k, x)); Console.ReadKey(); } } }