fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define fi first
  5. #define se second
  6. #define MOD 1000000007
  7. #define FOR(i,a,b) for (int i = (a);i <= (b);i++)
  8. #define FOD(i,a,b) for (int i = (b);i >= (a);i--)
  9. #define ALL(x) (x).begin(),(x).end()
  10. #define ii pair<ll,ll>
  11. #define iii pair<int,pair<int,int>>
  12. //const int MOD = 998244353;
  13. const int MAXN = 1e3 + 7;
  14. vector<int> v;
  15. bool Prime[MAXN];
  16. void sieve(){
  17. Prime[0] = Prime[1] = true;
  18. FOR(i,2,(int)sqrt(MAXN))
  19. if (!Prime[i])
  20. for (int j = i * i;j <= MAXN;j += i)
  21. Prime[j] = true;
  22. FOR(i,1,MAXN)if (!Prime[i])
  23. v.push_back(i);
  24. }
  25. int random(int l,int r){
  26. return l + rand() % (r - l + 1);
  27. }
  28. int Pow(int a,int b,int mod){
  29. if (b == 1)return a;
  30. ll x = Pow(a,b / 2,mod);
  31. if (b & 1)return x * x % mod * a % mod;
  32. return x * x % mod;
  33. }
  34. bool prime(int n){
  35. if (n == 2)return true;
  36. FOR(i,1,2){
  37. int x = random(2,n - 1);
  38. if (Pow(x,n - 1,n) != 1)return false;
  39. }
  40. return true;
  41. }
  42. bool is_square(int n){
  43. int c = sqrt(n + 4);
  44. return c * c == n || (c - 1) * (c - 1) == n;
  45. }
  46. int check(int n){
  47. int ans = 1;
  48. for (auto i : v)if (n % i == 0){
  49. int res = 1;
  50. while(n % i == 0){
  51. res++;
  52. n = n / i;
  53. }
  54. ans = ans * res;
  55. }else if (i * i * i > n)break;
  56. if (n > 1)
  57. if (prime(n))ans = ans * 2;
  58. else if (is_square(n))ans = ans * 3;
  59. else ans = ans * 4;
  60. return ans;
  61. }
  62. int main(){
  63. ios_base::sync_with_stdio(false);
  64. cin.tie(0); cout.tie(0);
  65. //freopen("MRG.INP","r",stdin);
  66. //freopen("MRG.OUT","w",stdout);
  67. srand(time(NULL));
  68. sieve();
  69. int l,r;cin >> l >> r;
  70. int q = 0,k,t,cnt = 0;
  71. FOR(i,l,r){
  72. int res = check(i);
  73. if (res > q){
  74. q = res;
  75. k = i;t = 0;
  76. }
  77. if (res == q)t++;
  78. }
  79. cout << q << ' ' << k << ' ' << t;
  80. return 0^0;
  81. }
Success #stdin #stdout 1.41s 5272KB
stdin
999000000 1000000000
stdout
1024 999999000 1