整数拆分
wiki上看到了一个厉害的递推式
#include <iostream>
using namespace std;
int main() {
const int len = 121;
int num[len + 1] = { 1 };
for (int i = 1; i <= len; ++i)
for (int j = i; j <= len; ++j)
num[j] += num[j - i];
for (int i = 0; i <= len; i++)
cout << i << ' ' << num[i] << endl;
return 0;
}

浙公网安备 33010602011771号