Files
python/TangDou/LianXiTi50/39.cpp

18 lines
338 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#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;
}