-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path10252.cpp
More file actions
53 lines (47 loc) · 789 Bytes
/
10252.cpp
File metadata and controls
53 lines (47 loc) · 789 Bytes
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
/* USER: 93043 (mkbs_cse09) */
/* PROBLEM: 1193 (10252 - Common Permutation) */
/* SUBMISSION: 09586762 */
/* SUBMISSION TIME: 2011-12-23 15:48:00 */
/* LANGUAGE: 1 */
#include <stdio.h>
int c1[26];
int c2[26];
char ch1[1005];
char ch2[1005];
int min(int a,int b)
{
if(a<b)
return a;
else
return b;
}
int main()
{
int i,j;
while(~scanf("%s",ch1))
{
scanf("%s",ch2);
for(i=0;i<26;i++)
{
c1[i]=c2[i]=0;
}
for(i=0;ch1[i]!='\0';i++)
{
c1[ch1[i]-'a']++;
}
for(i=0;ch2[i]!='\0';i++)
{
c2[ch2[i]-'a']++;
}
for(i=0;i<26;i++)
{
j = min(c1[i],c2[i]);
while(j-->0)
{
printf("%c",i+'a');
}
}
printf("\n");
}
return 0;
}