Advertisement
Ronka

Untitled

Jun 8th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 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 daysofweek
  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.  
  16.  
  17. long[] arr = new long[n];
  18. arr[0] = 1;
  19.  
  20. for (int i = 1; i < n; i++)
  21. {
  22. long sum = 0;
  23.  
  24. for (int j = i-1; j >=0 && j >= i-k; j--)
  25. {
  26. sum += arr[j];
  27. }
  28. arr[i] = sum;
  29. }
  30. Console.WriteLine(string.Join(" ", arr));
  31.  
  32.  
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement