LCP 2-分式化简

Posted angelica-duhurica

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LCP 2-分式化简相关的知识,希望对你有一定的参考价值。

LCP 2-分式化简

    public int[] fraction(int[] cont) {
        int len = cont.length;
        int[] d = new int[]{cont[len - 1], 1};
        while (len > 1) {
            d = get(cont[len - 2], d);
            len--;
        }

        return d;
    }

    private int[] get(int z, int[] c) {
        return new int[]{z * c[0] + c[1], c[0]};
    }

public int[] fraction(int[] cont) {
    int[] res = new int[2];
    res[0] = 1;
    for(int i = cont.length - 1; i >= 0; i--){
        int temp1 = res[1];
        res[1] = res[0];
        res[0] = cont[i] * res[1] + temp1;
    }
    return res;
}

以上是关于LCP 2-分式化简的主要内容,如果未能解决你的问题,请参考以下文章