fork download
  1. #include<stdio.h>
  2. #define ll long long
  3. #include<math.h>
  4. int snt(int n){
  5. if(n<2){
  6. return 0;
  7. }
  8. for(int i = 2; i <= sqrt(n); i++){
  9. if(n % i == 0){
  10. return 0;
  11. }
  12. }
  13. return 1;
  14. }
  15. int main(){
  16. int a[100000];
  17. int n = 0;
  18. int tmp ;
  19. while(scanf("%d", &tmp) != -1){
  20. a[n] = tmp;
  21. ++n;
  22. }
  23. for(int i = 0; i < n; i++){
  24. int check = 1;
  25. for(int j = 0; j < i ;j++){
  26. if(a[i] == a[j]){
  27. check = 0;
  28. break;
  29. }
  30. }
  31. if(check){
  32. if(snt(a[i])){
  33. int cnt = 1;
  34. for(int j = i + 1; j < n; j++){
  35. if(a[i] == a[j]){
  36. ++cnt;
  37. }
  38. }
  39. printf("%d %d\n", a[i], cnt);
  40. }
  41. }
  42. }
  43. return 0;
  44. }
Success #stdin #stdout 0s 5276KB
stdin
Standard input is empty
stdout
Standard output is empty