[ACM]Q10407: Simple division
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Q10407
{
class Program
{
static private int[] iarr; static private char[] par = { ' ' }; static private int temp; static private bool tof;
static void Main(string[] args)
{
for (; ; )
{
label: Console.Write("Integer>>>");
try
{
iarr = Array.ConvertAll<string, int>(Console.ReadLine().Split(par, StringSplitOptions.RemoveEmptyEntries), int.Parse);
}
catch { goto label; }
tof = true;
for (int j = Math.Abs(iarr.Min()); j >= 1; j--)
{
int t1 = iarr[0] % j; int t2 = iarr[1] % j;
if (t1 < 0) t1 += j; if (t2 < 0) t2 += j;
if (t1 == t2)
{
temp = t1;
for (int i = 2; i < iarr.Length; i++)
{
t2 = iarr[i] % j; t2 += t2 < 0 ? j : 0;
if (temp != t2) break;
if (i == iarr.Length - 1) { Console.WriteLine("Ans={0}", j); tof = false; }
}
}
if (!tof) break;
}
}
}
}
}