Files
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

18 lines
338 B
C++

#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
double s = 0;
if (n % 2 == 0) {
for (int i = 2; i <= n; i = i + 2)
s += 1.0 / i;
} else {
for (int i = 1; i <= n; i = i + 2)
s += 1.0 / i;
}
cout << s << endl;
return 0;
}