D.cpp 260 B

1234567891011121314151617
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. double s=0;
  5. for(int i=1;; i+=2) {
  6. double t=1.0/i;
  7. if(fabs(t)<1e-6)
  8. break;
  9. if(i%4==1)
  10. s+=t;
  11. else
  12. s-=t;
  13. }
  14. cout<<"PI="<<fixed<<setprecision(8)<<4*s<<endl;
  15. return 0;
  16. }