Program.cs 1000 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace D14._1
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. if (args.Length == 0) return;
  13. int input = int.Parse(args[0]);
  14. int elf1 = 0;
  15. int elf2 = 1;
  16. List<int> recipes = new List<int>() { 3, 7 };
  17. for (int _ = 0; _ < 10 + input; ++_)
  18. {
  19. int nrecipe = recipes[elf1] + recipes[elf2];
  20. if (nrecipe < 10) recipes.Add(nrecipe);
  21. else recipes.AddRange(new[] { 1, nrecipe - 10 });
  22. elf1 = (elf1 + 1 + recipes[elf1]) % recipes.Count;
  23. elf2 = (elf2 + 1 + recipes[elf2]) % recipes.Count;
  24. }
  25. string result = "";
  26. for (int i = input; i < 10 + input; ++i)
  27. result += recipes[i].ToString();
  28. Console.WriteLine(result);
  29. }
  30. }
  31. }