Initial commit
This commit is contained in:
commit
bdf71aef37
120 files changed
+8284
No files matched your search
@@ -0,0 +1,26 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char const *argv[]) {
|
||||
double eps;
|
||||
double pi;
|
||||
double sum = 0;
|
||||
int sign = 1;
|
||||
|
||||
scanf("%lf", &eps);
|
||||
|
||||
for (int i = 0;; i++) {
|
||||
double x = sign / (sqrt(3) * pow(3, i) * (2 * i + 1));
|
||||
sum += sign / (sqrt(3) * pow(3, i) * (2 * i + 1));
|
||||
sign = -sign;
|
||||
if (1 / (sqrt(3) * pow(3, i) * (2 * i + 1)) < eps)
|
||||
break;
|
||||
}
|
||||
|
||||
pi = 6 * sum;
|
||||
|
||||
printf("pi=%f\n", pi);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user