| 1234567891011121314151617181920212223242526272829303132333435363738 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace D14._1
- {
- class Program
- {
- static void Main(string[] args)
- {
- if (args.Length == 0) return;
- int input = int.Parse(args[0]);
- int elf1 = 0;
- int elf2 = 1;
- List<int> recipes = new List<int>() { 3, 7 };
- for (int _ = 0; _ < 10 + input; ++_)
- {
- int nrecipe = recipes[elf1] + recipes[elf2];
- if (nrecipe < 10) recipes.Add(nrecipe);
- else recipes.AddRange(new[] { 1, nrecipe - 10 });
- elf1 = (elf1 + 1 + recipes[elf1]) % recipes.Count;
- elf2 = (elf2 + 1 + recipes[elf2]) % recipes.Count;
- }
- string result = "";
- for (int i = input; i < 10 + input; ++i)
- result += recipes[i].ToString();
- Console.WriteLine(result);
- }
- }
- }
|