提交时间:2024-10-27 10:08:00
运行 ID: 54318
#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; double sum = 0, a = 2, b = 1; for (int i = 1; i <= n; i++) { sum += a / b; long long temp = a; a = a + b; b = temp; } cout << fixed << setprecision(4) << sum << endl; return 0; }