//C(n,r)
int c(int n,int r){
int c=1;
for(int i=0;i<r;i++) c=c*(n-i)/(i+1);
return c;
}
//排列生成函数 next_permutation
string str;
cin >> str;
sort(str.begin(), str.end());
cout << str << endl;
while(next_permutation(str.begin(), str.end())){
cout << str << endl;
}
//母函数模板
const int maxn = 10010;
int c1[maxn], c2[maxn];
int main()
{
int num;
int i,j,k;
while(~scanf("%d", &num)){
for(int i = 0; i <= num; i++){
c1[i] = 1;
c2[i] = 0;
}
for(int i = 2; i <= num; i++){
for(int j = 0; j <= num; j++){
for(int k = 0; k+j <= num; k += i){
c2[j+k] += c1[j];
}
}
for(int j = 0; j <= num; j++){
c1[j] = c2[j];
c2[j] = 0;
}
}
printf("%d\n", c1[num]);
}
}
ACM 组合数学
最新推荐文章于 2022-09-27 14:48:28 发布