-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10789.cpp
More file actions
50 lines (49 loc) · 1.01 KB
/
10789.cpp
File metadata and controls
50 lines (49 loc) · 1.01 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
#include <bits/stdc++.h>
int prime(int n) {
int i;
if (n == 1) return 0;
if (n == 2) return 1;
if (n % 2 == 0) return 0;
for (i = 3; i * i <= n; i += 2) {
if (n % i == 0) {
return 0;
}
}
return 1;
}
int main() {
int n, t, l, i, j, c;
int b[123];
char a[5000];
scanf("%d", &t);
getchar();
for (j = 1; j <= t; j++) {
for (i = 0; i <= 122; i++) {
b[i] = 0;
}
gets(a);
l = strlen(a);
std::sort(a, a + l);
for (i = 0; i <= l; i++) {
n = a[i];
b[n]++;
}
for (i = 48; i <= 122; i++) {
if (prime(b[i]) == 0) {
b[i] = 0;
}
}
printf("Case %d: ", j);
c = 0;
for (i = 48; i <= 122; i++) {
if (b[i] != 0) {
printf("%c", i);
c = 1;
}
}
if (c == 0) {
printf("empty");
}
printf("\n");
}
}