#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <gmp.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <pthread.h>
int main(int argc, char *argv[]){
setpriority(0, 0, 19);
mpf_t a_k, a_sum, b_sum, C, C3;
mpf_t k, tmp1, tmp2, tmp3, n1, total, pi;
mpf_t one;
int i;
mpf_set_default_prec(3330000);
mpf_init(k);
mpf_init(a_k);
mpf_init(a_sum);
mpf_init(b_sum);
mpf_init(C);
mpf_init(C3);
mpf_init(tmp1);
mpf_init(tmp2);
mpf_init(tmp3);
mpf_init(total);
mpf_init(pi);
mpf_init(n1);
mpf_init(one);
mpf_set_str(k, "1", 10);
mpf_set_str(a_k, "1000", 10);
mpf_set_str(a_sum, "1000", 10);
mpf_set_str(b_sum, "0", 10);
mpf_set_str(C, "640320", 10);
mpf_set_str(n1, "-1", 10);
mpf_pow_ui(C3, C, (unsigned long int) 3);
mpf_div_ui(C3, C3, (unsigned long int) 24);
i = 0;
while(1){
i++;
mpf_mul_ui(tmp1, k, (unsigned long int) 6);
mpf_mul_ui(tmp2, k, (unsigned long int) 2);
mpf_sub_ui(tmp3, tmp1, (unsigned long int) 1);
mpf_sub_ui(tmp2, tmp2, (unsigned long int) 1);
mpf_sub_ui(tmp1, tmp1, (unsigned long int) 5);
mpf_mul(tmp1, tmp1, tmp2);
mpf_mul(tmp1, tmp1, tmp3);
mpf_mul(tmp1, tmp1, n1);
mpf_mul(a_k, a_k, tmp1);
mpf_pow_ui(tmp1, k, (unsigned long int) 3);
mpf_mul(tmp1, tmp1, C3);
mpf_div(a_k, a_k, tmp1);
mpf_add(a_sum, a_sum, a_k);
mpf_mul(tmp1, k, a_k);
mpf_add(b_sum, b_sum, tmp1);
mpf_add_ui(k, k, (unsigned long int) 1);
if(i == 70514) break;
}
mpf_mul_ui(a_sum, a_sum, (unsigned long int) 13591409);
mpf_mul_ui(b_sum, b_sum, (unsigned long int) 545140134);
mpf_add(total, a_sum, b_sum);
mpf_set_str(tmp1, "10005", 10);
mpf_sqrt(tmp1, tmp1);
mpf_mul_ui(tmp1, tmp1, (unsigned long int) 426880);
mpf_div(pi, tmp1, total);
gmp_printf("%.Ff\n", pi);
mpf_clear(k);
mpf_clear(a_k);
mpf_clear(a_sum);
mpf_clear(C);
mpf_clear(tmp1);
mpf_clear(tmp2);
mpf_clear(tmp3);
mpf_clear(total);
mpf_clear(pi);
mpf_clear(n1);
mpf_clear(one);
}