LCP 2-分式化简
2024-09-06 17:56:29
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;
}
最新文章
- Tween公式 以及四个参数
- word
- c#基础之长度可变类型相同的参数列表
- [转]maven安装以及eclipse配置maven
- 序列化SerialVersionUID
- Git:代码冲突常见解决方法
- spring事物传播机制 事物隔离级别
- 基于ACE的定时器模板类
- ubuntu14.04 为Firefox安装flash插件
- Ubuntu上搭建DokuWiki
- 新安装Win10
- Spring-Mybatis配置多数据源
- IDEA-最简单的struts2项目 关于lib项目的默认位置
- [Noi2014]购票
- 作为JavaScript开发人员,这些必备的VS Code插件你都用过吗?
- 【转载】MySQL5.7 添加用户、删除用户与授权
- LCD调试1.0
- android gradle tools 3.X中dependencies, implementation和compile区别
- 12.8 Daily Scrum
- pta6-17(另类堆栈)