文章
84
粉丝
408
获赞
33
访问
877.8k
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int n;
cin >> n;
int* a = new int[n];
int* b = new int[n];
a[0] = 1, b[0] = 2;
double ans = 2.0;
for (int i = 1; i < n; i++) {
a[i] = b[i-1];
b[i] = a[i-1] + b[i-1];
ans += 1.0*b[i]/a[i];
}
printf("%.2f\n", ans);
return 0;
}
登录后发布评论
暂无评论,来抢沙发