思路:
水题,略过
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; }