@qqiseeu
2014-04-01T12:24:00.000000Z
字数 1026
阅读 3689
给定三个数10011。数据范围为:
以
for (int i=0; i<=N; i++)F[0][i] = F[i][0] = 1;for (int i=1; i<=N; i++)for (int j=1; j<=L; j++)F[i][j] = F[i-1][j] + F[i-1][j-1];
注意到
综上得出核心部分的代码:
lower_bound = L;rest = I;while (rest > 1){for (int i=1; i<=N; i++)if (F[i][lower_bound] >= rest){S[i-1] = 1;rest -= F[i-1][lower_bound];lower_bound--;break;}}
另外要注意变量的类型,I和rest都应该是long以上类型。