Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace RecursiveNK
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int k = int.Parse(Console.ReadLine());
- Console.WriteLine(String.Join(" ", Solve(n, k)));
- }
- public static List<int> Solve(int n, int k)
- {
- return n == 1 ? new List<int>() { 1 } : Solve(n - 1, k).Concat(new List<int>() { Solve(n - 1, k).Skip(Math.Max(0, Solve(n - 1, k).Count() - k)).Sum() }).ToList();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement