using System; public abstract class IntSequence { public abstract int Min {get;} public abstract int Max {get;} public abstract int Sum(); } public class IntInterval: IntSequence{ private int from, to; public IntInterval(int from, int to){ this.from = from; this.to = to; } public int From{ get{return from;} } public int To{ get{return to;} } public override int Min{ get {return Math.Min(from,to);} } public override int Max{ get {return Math.Max(from,to);} } public override int Sum(){ int res = 0; int lower = Math.Min(from,to), upper = Math.Max(from,to); for (int i = lower; i <= upper; i++) res += i; return res; } } public class IntSingular: IntSequence{ private int it; public IntSingular(int it){ this.it = it; } public int TheInt{ get{return it;} } public override int Min{ get {return it;} } public override int Max{ get {return it;} } public override int Sum(){ return it; } } public class IntCompSeq: IntSequence{ private IntSequence s1, s2; // Binary sequence: Exactly two subsequences. public IntCompSeq(IntSequence s1, IntSequence s2) { this.s1 = s1; this.s2 = s2; } public IntSequence First{ get{return s1;} } public IntSequence Second{ get{return s2;} } public override int Min{ get {return Math.Min(s1.Min, s2.Min);} } public override int Max{ get {return Math.Max(s1.Max, s2.Max);} } public override int Sum(){ return s1.Sum() + s2.Sum(); } }