Advertisement
Guest User

Untitled

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