Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t,n,k,i,j,l,ans;
- scanf("%d",&t);
- for(i=1; i<=t; i++)
- {
- scanf("%d %d",&n,&k);
- char s[n];
- for(j=0; j<n; j++)
- {
- s[j]='A'+j;
- }
- s[n]=0;
- ans=1;
- for(j=1; j<=n; j++)
- {
- ans=ans*j;
- }
- printf("Case %d:\n",i);
- if(ans<k)
- {
- for(l=0; l<ans; l++)
- {
- printf("%s\n",s);
- next_permutation(s,s+n);
- }
- }
- else
- {
- for(l=0; l<k; l++)
- {
- printf("%s\n",s);
- next_permutation(s,s+n);
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement