題解 | #統(tǒng)計(jì)每個(gè)月兔子的總數(shù)#
統(tǒng)計(jì)每個(gè)月兔子的總數(shù)
http://fangfengwang8.cn/practice/1221ec77125d4370833fd3ad5ba72395
#include<iostream> #include<cmath> #include<algorithm> #include <ostream> using namespace std; int main(){ int n; long ans; while(cin >> n){ double sqrt5 = sqrt(5); double fibN = pow((1 + sqrt5) / 2, n) - pow((1 - sqrt5) / 2, n); ans = round(fibN / sqrt5); cout << ans << endl; } return 0; }