样例、自己的样例全过,10分,求调
查看原帖
样例、自己的样例全过,10分,求调
1390743
_mei_tou_nao_楼主2024/8/12 10:06
using namespace std;
int  f[31], x[31], a[31], b;
double n, y, z, c = 3.5000;

int main() {
	cin >> b;
	f[1] = 1;
	f[2] = 2;
	x[1] = 2;
	x[2] = 3;
	for (int i = 3; i <= b; i++) {
		f[i] = f[i - 1] + f[i - 2];
		n += f[i];
		x[i] = x[i - 1] + x[i - 2];
		y += x[i];
		z = y / n;
		c += z;
	}
	if (b == 1) {
		c = 2.0000;
	}
	if (b == 0) {
		c = 0.0000;
	}
	cout << setprecision(4) << fixed << c ;
	return 0;
}```友关!!
2024/8/12 10:06
加载中...