D.cpp 360 B

12345678910111213141516171819
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. int n;
  5. while (cin >> n) {
  6. double pi = 0.0;
  7. for (int i = 1; i <= n; i += 2) {
  8. if (i % 4 == 1) {
  9. pi += 1.0 / i;
  10. } else {
  11. pi -= 1.0 / i;
  12. }
  13. }
  14. cout << fixed << 4 * pi << endl;
  15. }
  16. return 0;
  17. }