fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int N[1001] = {1, 1};
  5.  
  6. int partition(int n){
  7. if(N[n] != 0) return N[n];
  8. int total;
  9. for(int t = n / 2;t>=0;t--) total += partition(t);
  10. N[n] = total;
  11. return total;
  12. }
  13.  
  14. int main(void) {
  15. int n;
  16. scanf("%d", &n);
  17. printf("%d",partition(n));
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 5316KB
stdin
7
stdout
6