Program.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.IO;
  3. using System.Text.RegularExpressions;
  4. namespace D25._1
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. if (args.Length < 1) throw new ArgumentException();
  11. if (File.Exists(args[0]) == false) throw new FileNotFoundException();
  12. int row = 1, col = 1;
  13. ulong n = 20151125;
  14. var regex = new Regex(@"row (?<r>\d+), column (?<c>\d+)");
  15. string input = File.ReadAllText(args[0]);
  16. var result = regex.Match(input);
  17. var breakRow = int.Parse(result.Groups["r"].Value);
  18. var breakColumn = int.Parse(result.Groups["c"].Value);
  19. while (true)
  20. {
  21. row--;
  22. col++;
  23. if (row == 0)
  24. {
  25. row = col;
  26. col = 1;
  27. }
  28. n = (n * 252533) % 33554393;
  29. if (row == breakRow && col == breakColumn)
  30. break;
  31. }
  32. Console.WriteLine($"Answer is : {n}");
  33. }
  34. }
  35. }