示例#1
0
    bool Check(int[] A, int P)
    {
        var S = new Integer(A[0], P);

        S.Check();
        foreach (var a in A.Skip(1))
        {
            if (a > S.Length)
            {
                S.Add(a - S.Length); S.Check();
            }
            else
            {
                S.Cut(a);
                S.Check();
                if (!S.Increment())
                {
                    return(false);
                }
                S.Check();
            }
            if (S.Length != a)
            {
                throw new Exception();
            }
            // WriteLine(S);
        }
        return(true);
    }