Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, x, i, maxim, nr, j , ct, prim;
  6. cin >> n;
  7. maxim = 0; ct = 0;
  8.  
  9. for (i = 1; i <= n; i++) {
  10. cin >> x;
  11. prim = 1;
  12. if (x < 2) {
  13. prim = 0;
  14. }
  15. else for (j = 2; j * j <= x; j++) {
  16. if (n % i == 0) {
  17. prim = 0;
  18. break;
  19. }
  20. }
  21. if (prim == 1 && x > maxim){
  22. maxim = x;
  23. ct = 1;
  24. }
  25. else if (prim == 1 && x == maxim) {
  26. ct ++;
  27. }
  28. }
  29.  
  30. if (ct > 0) cout << maxim << " " << ct;
  31. else if (ct == 0) cout << "NU EXISTA";
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement