嗨我非常package stackoverflow;
import java.math.BigInteger;
public class Fibonacci {
public static class Matrix {
BigInteger[][] a;
public Matrix(BigInteger n0, BigInteger n1, BigInteger n2, BigInteger n3) {
a = new BigInteger[][]{{n0, n1}, {n2, n3}};
}
public BigInteger get(int i, int j) {
return a[i][j];
}
@Override
public String toString() {
return String.format("%s %s\n%s %s", a[0][0], a[0][1], a[1][0], a[1][1]);
}
}
Matrix matrixMult(Matrix a, Matrix b) {
return new Matrix(a.get(0, 0).multiply(b.get(0, 0)).add(a.get(0, 1).multiply(b.get(1, 0))),
a.get(0, 0).multiply(b.get(0, 1)).add(a.get(0, 1).multiply(b.get(1, 1))),
a.get(1, 0).multiply(b.get(0, 0)).add(a.get(1, 1).multiply(b.get(1, 0))),
a.get(1, 0).multiply(b.get(0, 1)).add(a.get(1, 1).multiply(b.get(1, 1))));
}
Matrix power(Matrix a, int k) {
if (k == 0)
return new Matrix(new BigInteger("1"), new BigInteger("0"),
new BigInteger("0"), new BigInteger("1"));
Matrix t = power(a, k / 2);
Matrix t2 = matrixMult(t, t);
if (k % 2 == 0)
return t2;
return matrixMult(t2, a);
}
BigInteger get(int n) {
Matrix a = new Matrix(new BigInteger("1"), new BigInteger("1"),
new BigInteger("1"), new BigInteger("0"));
return power(a, n).get(0, 1);
}
String getFirstK(int n, int k) {
return get(n).toString().substring(0, k);
}
public static void main(String[] args) {
Fibonacci f = new Fibonacci();
System.out.println(f.getFirstK(200000, 10));
}
}
用于安卓,我已经在我的空白活动中以编程方式添加了相对布局,所以一切都很好
这里我的主要要求是我想在四边设置相对布局的边距,为此我尝试了一些代码,但那不起作用请帮帮我
begginer
答案 0 :(得分:1)
设置边距后,只需致电setLayoutParams()
:
layoutParams.setMargins(10, 10, 10, 10);
ll.setLayoutParams(layoutParams);// here
setContentView(ll);
PS:在您的情况下,如果您从xml
设置RelativeLayout
,则会更好
答案 1 :(得分:-1)
以防您需要XML格式
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dip">
</RelativeLayout>
或者你可以设置一个
android:layout_marginBottom="10dip"
android:layout_marginTop="10dip"
等等