2020年团体程序设计天梯赛 L1-4 调和平均
思路:
水题,略过
Tip:
注意for循环中不要cin读入double数组,队友亲自实验读入数组会WA测试点2
#include <bits/stdc++.h>
using namespace std;
int main() {
double n;
double ans = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
double tmp;
cin >> tmp;
tmp = 1.0 / tmp;
ans += tmp;
}
ans = n/ans;
printf("%.2lf", ans);
return 0;
}

浙公网安备 33010602011771号