Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CrossingSequences
- {
- class crossingSequences
- {
- static void Main(string[] args)
- {
- long a = long.Parse(Console.ReadLine());
- long b = long.Parse(Console.ReadLine());
- long c = long.Parse(Console.ReadLine());
- long n = long.Parse(Console.ReadLine());
- long step = long.Parse(Console.ReadLine());
- long count = 0;
- List<long> tribonacci = new List<long>();
- for (long i = c; i <= 10000000; i += (a + b))
- {
- tribonacci.Add(a);
- long sum = a + b + c;
- a = b;
- b = c;
- c = sum;
- }
- for (long j = n; j <= 1000000; j += step)
- {
- if (count != 0 && count % 2 == 0)
- {
- step += 2;
- }
- count++;
- if (tribonacci.Contains(j))
- {
- Console.WriteLine(j);
- return;
- }
- }
- Console.WriteLine("No");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement