#include <stdio.h>
char n[10000];
int count[26]={0};
int cnt[26][2]={0};
int collect[26]={0};
int word(void); //문자 개수 세기
int research(int c); //소수문자열 찾기
void pr(int c2); //결과 출력
int main(void)
{
int c, c2;
scanf("%s", n);
c=word();
c2=research(c);
//line(c2);
pr(c2);
return 0;
}
int word(void)
{
int i, c=0;
for(i=0; n[i]!='\0'; i++)
{
count[n[i]-'A']++; //개수
}
for(i=0; i<26; i++)
{
if(count[i]!=0)
{
cnt[c][0]=i+'A';
cnt[c++][1]=count[i];
}
}
return c;
}
int research(int c)
{
int i, j, a, c2=0;
for(i=0; i<c; i++)
{
a=1;
for(j=2; j<=(cnt[i][1]/2); j++)
{
a=0;
if(cnt[i][1]%j==0)
{
a=1;
break;
}
}
if(cnt[i][1]==2 || cnt[i][1]==3 || a==0)
{
collect[c2++]=cnt[i][0];
}
}
return c2;
}
void pr(int c2)
{
int i;
if(collect[0]==0)
printf("NONE");
else
{
for(i=0; i<c2; i++)
{
printf("%c", collect[i]);
}
}
}
2018.01.20 11:33
정올 - 실력키우기 - 소수문자열(1566)
조회 수 272 추천 수 0 댓글 0