monoteen

PI

Jun 6th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #pragma warning(disable:4996)
  3. #define SCALE      10000
  4. #define MAX_ARRAY   200000
  5. #define ARRAY_INIT  2000
  6.  
  7. int main(void)
  8. {
  9.     int i, j, sum, carry = 0;
  10.     int array[MAX_ARRAY + 1];
  11.     int inin;
  12.  
  13.     for (i = 0; i <= MAX_ARRAY; ++i) array[i] = ARRAY_INIT;
  14.  
  15.     for (i = MAX_ARRAY; i; i -= 14) {
  16.         sum = 0;
  17.         for (j = i; j > 0; --j) {
  18.             sum = sum * j + SCALE * array[j];
  19.             array[j] = sum % (j * 2 - 1);
  20.             sum /= (j * 2 - 1);
  21.         }
  22.  
  23.         printf("%04d", carry + sum / SCALE);
  24.         carry = sum % SCALE;
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment