using System; using System.IO; using System.Text.RegularExpressions; namespace D25._1 { class Program { static void Main(string[] args) { if (args.Length < 1) throw new ArgumentException(); if (File.Exists(args[0]) == false) throw new FileNotFoundException(); int row = 1, col = 1; ulong n = 20151125; var regex = new Regex(@"row (?\d+), column (?\d+)"); string input = File.ReadAllText(args[0]); var result = regex.Match(input); var breakRow = int.Parse(result.Groups["r"].Value); var breakColumn = int.Parse(result.Groups["c"].Value); while (true) { row--; col++; if (row == 0) { row = col; col = 1; } n = (n * 252533) % 33554393; if (row == breakRow && col == breakColumn) break; } Console.WriteLine($"Answer is : {n}"); } } }