-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1384.cpp
More file actions
62 lines (53 loc) · 1.13 KB
/
1384.cpp
File metadata and controls
62 lines (53 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*************************************************************************
> File Name: 1384.cpp
> Author: dulun
> Mail: [email protected]
> Created Time: 2016年03月04日 星期五 13时45分52秒
************************************************************************/
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define LL long long
using namespace std;
const int N = 11;
char s[N];
int a[N];
int p[N];
int list[N];
void print(int n, int cnt)
{
if(n == cnt)
{
for(int i = 0; i < n; i++) printf("%d", a[i]);
printf("\n");
}
else{
for(int i = 0; i < n; i++)
if(!i || p[i] != p[i-1])
{
int c1 = 0, c2 = 0;
for(int j = 0; j < cnt; j++) if(a[j] == p[i]) c1++;
if(c1 < list[p[i]])
{
a[cnt] = p[i];
print(n, cnt+1);
}
}
}
}
int main()
{
cin>>s;
int list2[N];
int l = strlen(s);
for(int i = 0; i < l; i++)
{
p[i] = s[i] - '0';
list[p[i]] += 1;
}
sort(p, p+l);
print(l, 0);
return 0;
}