// part.c: partition function
#include <stdio.h>
double total = 0;
double tot0 = 0;
double totgt0 = 0;
double totlt0 = 0;
//int count[300];

int p(int n) {
   int sign;
   double res;
   double term;
   int k;
   double n1, n2;
   if (n > 0) totgt0++;
   else if (n == 0) tot0++;
   else if (n < 0)  totlt0++;
   if (n < 0) return 0;
   if (n == 0) return 1;
   sign = 1;
   res = 0;
   for (k = 1; k <= n; k++) {
      n1 = n - k*(3*k - 1)/2;
      n2 = n - k*(3*k + 1)/2;
      term = p(n1) + p(n2);
      res = res + sign*term;
      sign = -sign;
   }
   return res;
}

int main() {
   int n = 45;
   double res;
   res = p(n);
   total = totgt0+tot0+totlt0;
   printf("%3i,%20.0f\n", n, res);
   printf("tot:%20.0f\n", total);
   printf("==0:%20.0f, %20.16f\n", tot0, tot0 / total*100);
   printf(" >0:%20.0f, %20.16f\n", totgt0, totgt0 / total*100);
   printf(" <0:%20.0f, %20.16f\n", totlt0, totlt0 / total*100);
}