nassss

Untitled

Mar 7th, 2020
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _2._Sequence
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. var input = Console.ReadLine()
  12. .Split(' ')
  13. .Select(int.Parse)
  14. .ToArray();
  15.  
  16. var queue = new Queue<long>();
  17. queue.Enqueue(input[0]);
  18.  
  19. long firstVar = input[0];
  20. long secondVar = 0;
  21. long thirdVar = 0;
  22. long fourthVar = 0;
  23.  
  24. while (firstVar != input[1] && secondVar != input[1] && thirdVar != input[1] && fourthVar != input[1])
  25. {
  26. firstVar = queue.Dequeue();
  27. secondVar = firstVar + 1;
  28. queue.Enqueue(secondVar);
  29. thirdVar = 2 * firstVar + 1;
  30. queue.Enqueue(thirdVar);
  31. fourthVar = firstVar + 2;
  32. queue.Enqueue(fourthVar);
  33. }
  34. Console.WriteLine(input[1]);
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment