using System; using System.Collections; using System.Collections.Generic; using System.Drawing; namespace A333825 { class Program { static void Main(string[] args) { List seq = new List(); Point z = new Point(); int n = 0; while (!Out(z) && seq.Count<10000) { n++; if (!Seen(z)) { foreach (Point p in seq) { See(z, Dir(z, p)); See(z, Dir(p, z)); } seq.Add(z); Console.WriteLine("{0} {1}", seq.Count, n); } z = Move(z); } } static Point Move(Point z) { int w = Math.Max(Math.Abs(z.X), Math.Abs(z.Y)); if (z.Y==-w) { return z + new Size(1, 0); } else if (z.X==-w) { return z + new Size(0, -1); } else if (z.Y==w) { return z + new Size(-1, 0); } else { return z + new Size(0,1); } } static bool Out(Point z) { return Math.Max(Math.Abs(z.X), Math.Abs(z.Y)) > W; } static bool Seen(Point z) { return seen[z.X + W][z.Y + W]; } static void See(Point z) { seen[z.X + W][z.Y + W] = true; } static void See(Point z, Size dz) { while (!Out(z)) { See(z); z += dz; } } static Size Dir(Point a, Point b) { int dx = b.X - a.X; int dy = b.Y - a.Y; int g = GCD(Math.Abs(dx), Math.Abs(dy)); return new Size(dx / g, dy / g); } private static int GCD(int a, int b) { while (a != 0 && b != 0) { if (a > b) a %= b; else b %= a; } return a == 0 ? b : a; } private const int W = 5000; private static readonly BitArray[] seen = new BitArray[2 * W + 1]; static Program() { for (int m = 0; m < seen.Length; m++) { seen[m] = new BitArray(2 * W + 1); } } } }