Advertisement
raisul82

UVA 10789 - Prime Frequency

Feb 24th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. char arr[10000],arr2[10000];
  6. int t,a=1,arr3[10000];
  7. scanf("%d",&t);
  8. while(t-- && scanf("%s",&arr))
  9. {
  10.  
  11. int k=strlen(arr),countt=0,n=0,f=0,q,h,flag=0;
  12. sort(arr,arr+k);
  13.  
  14. for(int i=0; i<k; i++)
  15. {
  16. if(arr[i]==arr[i+1])
  17. {
  18. countt++;
  19. n=countt;
  20. }
  21. else
  22. {
  23. countt=0;
  24. arr2[f]=arr[i];
  25. arr3[f]=n+1;
  26. n=0;
  27. f++;
  28. }
  29. }
  30. printf("Case %d: ",a);
  31. for(int m=0; m<f; m++)
  32. {
  33. h=0;
  34. q=sqrt(arr3[m]);
  35.  
  36. for(int g=2; g<=q; g++)
  37. {
  38. if(arr3[m]%g==0)
  39. {
  40. h=1;
  41. }
  42. }
  43. if(h==0 && arr3[m]!=1)
  44. {
  45. flag=1;
  46. printf("%c",arr2[m]);
  47. }
  48. }
  49. if(flag==0)
  50. {
  51. printf("empty");
  52. }
  53. a++;
  54. printf("\n");
  55. }
  56.  
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement