-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10789.cpp
62 lines (59 loc) · 1.11 KB
/
10789.cpp
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
/*
10789 - Prime Frequency
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
int test;
cin>>test;
for(int loop=1; loop<=test; loop++)
{
char aa[2020];
cin>>aa;
int freq[200]= {0};
int f=0,p=0,i,j,k;
for(int j=0; j<strlen(aa); j++)
{
freq[aa[j]]++;
}
printf("Case %d: ",loop);
for( k=48; k<=122; k++)
{
if(freq[k]!=0)
{
for(i=2; i<=sqrt(freq[k]); i++)
{
f=0;
if(freq[k]%i==0)
{
break;
}
else
{
f=1;
}
}
if(f==1 || freq[k]==2 || freq[k]==3)
{
printf("%c",k);
p=1;
}
}
}
if(p==1)printf("\n");
if(p==0)printf("empty\n");
}
return 0;
}
/*
Sample Input
3
ABCC
AABBBBDDDDD
ABCDFFFF
Sample Output
Case 1: C
Case 2: AD
Case 3: empty
*/