V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  mskf  ›  全部回复第 8 页 / 共 8 页
回复总数  146
1  2  3  4  5  6  7  8  
2017-11-20 12:51:38 +08:00
回复了 SkyKoo 创建的主题 机械键盘 Filco 的弹簧音
@shoaly 我的 filco 键盘也有弹簧音,你抹的是什么油
兄弟是在美国读书的吗,怎么去美国工作的
2017-11-18 17:12:07 +08:00
回复了 asj 创建的主题 上海 2017 代码静修日(Global Day of Coderetreat)上海站
@asj 刚看到。。。请问这种活动会不会经常举办啊,挺想去看看的
2017-11-18 15:19:36 +08:00
回复了 yasumoto 创建的主题 程序员 发现一个测常用字的网站,看看你们一分钟能打多少字
把上面的词连起来打就快很多了。。。125WPM
2017-11-18 14:58:52 +08:00
回复了 topfisc 创建的主题 程序员 曾经的百度,现在的大忽悠
笑出声。。。
//第一题:

public class Fibonacci {

/**
* /a b/
* /c d/
*/
private static class Matrix{
int a;
int b;
int c;
int d;

public Matrix(int a, int b, int c, int d) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
}

public static void main(String[] args) {
Arrays.asList(1,2,3,4,5,6,7,8,9,10).stream().forEach(n->System.out.println(fibonacci(n)));
}


public static int fibonacci(int n){
if(n==1)
return 0;
return Fib(n-1).b;
}

public static Matrix Fib(int n){
if(n==1)
return new Matrix(1,1,1,0);
return (n&1)==0?multi(Fib(n/2),Fib(n/2)):multi(Fib(n/2),Fib(n/2 + 1));
}

private static Matrix multi(Matrix m1,Matrix m2){
return new Matrix(
m1.a*m2.a+m1.b*m2.c,
m1.a*m2.b+m1.b*m2.d,
m1.c*m2.a+m1.d*m2.c,
m1.c*m2.b+m1.d*m2.d
);
}
}
1  2  3  4  5  6  7  8  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1155 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 18ms · UTC 23:31 · PVG 07:31 · LAX 16:31 · JFK 19:31
Developed with CodeLauncher
♥ Do have faith in what you're doing.