标签:main scan names iostream ios namespace name cst turn
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,vis[30];
void ans_out()
{
for(int i=1;i<=n;i++)
if(vis[i]) printf("%c",i+64);
printf("\n");
return;
}
void run(int x,int len)//考察数字x是否使用,len为之前用过的数字的数目;
{
if(x>n){
if(len==m) ans_out();
return;
}
for(int i=1;i>=0;i--)if(len<=m&&len+i+n-x>=m)
{
vis[x]=i;
run(x+1,len+i);
}
}
int main()
{
// freopen("test.in","r",stdin);
// freopen("test.out","w",stdout);
scanf("%d%d",&n,&m);
run(1,0);
return 0;
}
标签:main scan names iostream ios namespace name cst turn
原文地址:http://www.cnblogs.com/Bear-Child/p/6057014.html