Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 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 CrossingSequences
  8. {
  9. class crossingSequences
  10. {
  11. static void Main(string[] args)
  12. {
  13. long a = long.Parse(Console.ReadLine());
  14. long b = long.Parse(Console.ReadLine());
  15. long c = long.Parse(Console.ReadLine());
  16.  
  17. long n = long.Parse(Console.ReadLine());
  18. long step = long.Parse(Console.ReadLine());
  19. long count = 0;
  20. List<long> tribonacci = new List<long>();
  21. for (long i = c; i <= 10000000; i += (a + b))
  22. {
  23. tribonacci.Add(a);
  24. long sum = a + b + c;
  25. a = b;
  26. b = c;
  27. c = sum;
  28. }
  29. for (long j = n; j <= 1000000; j += step)
  30. {
  31. if (count != 0 && count % 2 == 0)
  32. {
  33. step += 2;
  34. }
  35. count++;
  36. if (tribonacci.Contains(j))
  37. {
  38. Console.WriteLine(j);
  39. return;
  40. }
  41. }
  42. Console.WriteLine("No");
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement