题目链接:
B-连分数_牛客小白月赛102 (nowcoder.com)
题目描述:
输入输出描述:
样例输入:
5
6.78
0.01
100.00
2.00
100000.00
样例输出:
6.924416500640523
1.005012499921876
100.009999000199950
2.414213562373095
100000.000010000000003
题目分析:
这个题,我都不好意思说我正在复习高数....,这个题wa了好几遍。
趋于无穷的时候,f(x)是等于f(x - 1)的,因此这个题就变成了 x = a + 1 / x, 问你x等于多少?
代码:
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define int long long
#define endl "\n"
using namespace std;
double a;
signed main() {
int t;
cin >> t;
while(t -- ) {
cin >> a;
printf("%.10lf\n", (a + sqrt(a * a + 4)) / 2.0);
}
return 0;
}