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 crossingSequences2
- {
- class crossingSequences2
- {
- static void Main(string[] args)
- {
- uint triA = uint.Parse(Console.ReadLine());
- uint triB = uint.Parse(Console.ReadLine());
- uint triC = uint.Parse(Console.ReadLine());
- uint spiralN = uint.Parse(Console.ReadLine());
- uint step = uint.Parse(Console.ReadLine());
- int count = 0;
- uint triD = 0;
- List<uint> tribonacci = new List<uint>();
- while (triA <= 1000000)
- {
- triD = triA + triB + triC;
- tribonacci.Add(triA);
- triA = triB;
- triB = triC;
- triC = triD;
- }
- while (spiralN <= 1000000)
- {
- count++;
- if (tribonacci.Contains(spiralN))
- {
- Console.WriteLine(spiralN);
- return;
- }
- spiralN += step;
- if (count % 2 == 0)
- step += 2;
- }
- Console.WriteLine("No");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement