斐波那契

class Solution {
public:
    int Fibonacci(int n) {
        double c1 = (1.0 + sqrt(5)) / 2, c2 = (1.0 - sqrt(5)) / 2;
        return (int)((pow(c1, n) - pow(c2, n)) / sqrt(5));
    }
};class Solution {
public:
    int Fibonacci(int n) {
        double c1 = (1.0 + sqrt(5)) / 2, c2 = (1.0 - sqrt(5)) / 2;
        return (int)((pow(c1, n) - pow(c2, n)) / sqrt(5));
    }
};

 

上一篇:HTML+CSS 鼠标悬停发光按钮


下一篇:++ -- 自增 ,自减 一元运算符