fork(2) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define rep(i,a,n) for(int i=a;i<n;i++)
  4. #define per(i,a,n) for(int i=n-1;i>=a;i--)
  5. #define VI vector<int>
  6. #define PII pair<int,int>
  7. #define pb push_back
  8. #define mp make_pair
  9. #define fi first
  10. #define se second
  11. #define ll long long
  12. #define db double
  13. #define all(x) (x).begin(),(x).end()
  14. #define sz(x) ((int)x.size())
  15. mt19937 mrand(random_device{}());
  16. const ll mod = 1000000007;
  17. int rnd(int x){return mrand()%x;}
  18. clock_t ac; double TLE(){return (double)(clock()-ac)/CLOCKS_PER_SEC;}
  19. void DBG() {cerr << "]" << endl;}
  20. template<class H, class... T> void DBG(H h, T... t) {
  21. cerr << to_string(h);
  22. if(sizeof...(t)) cerr << ", ";
  23. DBG(t...);}
  24. #ifdef _DEBUG
  25. #define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
  26. #else
  27. #define dbg(...) 0
  28. #endif
  29. #define MAXN 100007
  30. bool prime[MAXN];
  31. void sieve(){
  32. memset(prime,true,sizeof(prime));
  33. prime[0] = prime[1] = false;
  34. for (int i = 2; i <= MAXN; i++) {
  35. if (prime[i] && (long long)i * i <= MAXN) {
  36. for (int j = i * i; j <= MAXN; j += i)
  37. prime[j] = false;
  38. }
  39. }
  40. }
  41. int main(){
  42. ios::sync_with_stdio(0);
  43. cin.tie(0);
  44. sieve();
  45. int n;
  46. cin>>n;
  47. int a[n];
  48. for(int i=0;i<n;i++)cin>>a[i];
  49. map<int,int>m;
  50. int f=0;
  51. for(int i=0;i<n;i++){
  52. f=0;
  53. for(int j=2;j<=a[i];j++){
  54. if(a[i]%j==0&&prime[j]==true){
  55. m[j]++;
  56. f=1;
  57. }
  58. }
  59. if(f==0){
  60. m[a[i]]++;
  61. }
  62. }
  63. int cnt=0,ans=0;
  64. for(auto k: m){
  65. if(k.second>=cnt){
  66. cnt = k.second;
  67. ans = k.first;
  68. }
  69. }
  70. cout<<ans<<" "<<cnt<<"\n";
  71. }
Runtime error #stdin #stdout 0s 4536KB
stdin
Standard input is empty
stdout
Standard output is empty