// Date: 07-11-22 08-04-25 Khu namespace Problems { class GcdProblemQAI : DivisibleProblemQAI { protected GcdSolution solution; protected int p, q, r, s; protected override void CheckSolvability () { if (s == 0) { isDirectlySolvable = true; solution.Set(r); } } protected override void Divide () { System.Diagnostics.Debug.Assert (!isDirectlySolvable, "precondition"); int t = r % s; r = s; s = t; } public override Solution Solution () {return solution;} // no covariance! public int P {get {return p;}} public int Q {get {return q;}} public virtual void Set (int p, int q) { this.p = p; this.q = q; r = System.Math.Abs(p); s = System.Math.Abs(q); isDirectlySolvable = false; ComputeSolution(); } public GcdProblemQAI () { solution = new GcdSolution(); } } }