所以直接带入公式就可以过吗?
查看原帖
所以直接带入公式就可以过吗?
1030831
JadeSpring楼主2023/10/8 13:31
#include<iostream>
#include<iomanip>
#include<cmath>

using namespace std;

int main()
{
	int n;
	double fn = 0;
	cin >> n;
	fn = (pow((1 + sqrt(5)) / 2, n) - pow((1 - sqrt(5)) / 2, n)) / sqrt(5);

	cout << fixed << setprecision(2) << fn << endl;

	return 0;
}

直接带入公式就过了,怎么题解里都在用递归

2023/10/8 13:31
加载中...