#include <iostream> #include <string.h> constexpr int max = 39; long long p[max]; // A364752 bool z[max+1]; // z[v] = is v present? void explore(int prev) { p[prev]++; for (int v = prev ? prev+1 : 1; v<max; v++) { if (prev==0 || z[v-prev]) { z[v] = true; explore(v); z[v] = false; } } } int main() { memset(p, 0, sizeof(p)); memset(z, 0, sizeof(z)); explore(0); for (long long n=0; n<max; n++) { std::cout << n << ' ' << p[n] << std::endl; } return 0; }