Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace task_07
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. int k = int.Parse(Console.ReadLine());
  15. if (n <= 0)
  16. {
  17. Console.WriteLine(0);
  18. }
  19. else
  20. {
  21. int[] seq = new int[n];
  22. seq[0] = 1;
  23. for (int i = 1; i < n; i++)
  24. {
  25. for (int j = k; j > 0; j--)
  26. {
  27. if (i - j >= 0)
  28. {
  29. seq[i] = seq[i] + seq[i - j];
  30. }
  31. }
  32. }
  33. Console.WriteLine(string.Join(" ", seq));
  34. }
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement