fork download
  1. #include <bits/stdc++.h>
  2. #define FAST_READ ios_base::sync_with_stdio(0);
  3. #define ll long long
  4. #define pb push_back
  5. #define endl "\n"
  6. #define MAXN 200010
  7.  
  8. using namespace std;
  9.  
  10. ll T,n;
  11.  
  12. ll checkprost(ll cis)
  13. {
  14. if(cis==2 || cis==3)return 1;
  15. else if(cis==1 || cis%2==0 || cis%3==0)return 0;
  16. for(ll i=5,p=2;i*i<=cis;i+=p,p=6-p)
  17. {
  18. if(cis%i==0)return 0;
  19. }
  20. return 1;
  21. }
  22.  
  23. template<class U>
  24. vector<U> k_factors(U n)
  25. {
  26. vector<U> factors;
  27. vector<U>error;
  28. for (U f=2;f*f<=n;f++) {
  29. while (n%f == 0) {
  30. factors.pb(f);
  31. n/=f;
  32. }
  33. }
  34. if(n!=1)
  35. {
  36. factors.pb(n);
  37. return factors;
  38. }
  39. return factors;
  40. }
  41.  
  42.  
  43. set<ll>mn;
  44. int main(){
  45. FAST_READ;
  46. cin>>T;
  47. while(T--)
  48. {
  49. ll cnt=0;
  50. ll maxa=-123;
  51. cin>>n;
  52. //n++;
  53. ll ans=-123;
  54. for(ll i=1;i<=n;i++)
  55. {
  56. cnt=0;
  57. ll ciss=i;
  58. vector<ll>delit=k_factors(ciss);
  59. ll raz=delit.size();
  60. if(raz>maxa){maxa=raz;ans=i;}
  61. else if(raz==maxa)
  62. {
  63. if(i>ans)
  64. {
  65. ans=i;
  66. }
  67. }
  68.  
  69. }
  70. cout<<ans<<endl;
  71.  
  72. }
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79. return 0;
  80. }
Success #stdin #stdout 0s 16064KB
stdin
1
7
stdout
6