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 = 1e5 + 7;
  14. int random(int l,int r){
  15. return l + rand() % (r - l + 1);
  16. }
  17. int Pow(int a,int b,int mod){
  18. if (b == 1)return a;
  19. ll x = Pow(a,b / 2,mod);
  20. if (b & 1)return x * x % mod * a % mod;
  21. return x * x % mod;
  22. }
  23. bool prime(int n){
  24. if (n == 2)return true;
  25. FOR(i,1,1){
  26. int x = random(2,n - 1);
  27. if (Pow(x,n - 1,n) != 1)return false;
  28. }
  29. return true;
  30. }
  31. int check(int n){
  32. if (prime(n))return 2;
  33. int ans = 1;
  34. FOR(i,2,(int)sqrt(n))if (n % i == 0){
  35. int res = 1;
  36. while(n % i == 0){
  37. res++;
  38. n = n / i;
  39. }
  40. ans = ans * res;
  41. }
  42. if (n > 1)ans = ans * 2;
  43. return ans;
  44. }
  45. int main(){
  46. ios_base::sync_with_stdio(false);
  47. cin.tie(0); cout.tie(0);
  48. //freopen("MRG.INP","r",stdin);
  49. //freopen("MRG.OUT","w",stdout);
  50. srand(time(NULL));
  51. int l,r;cin >> l >> r;
  52. int q = 0,k,t,cnt = 0;
  53. FOR(i,l,r){
  54. cnt++;
  55. if (cnt == 10000)break;
  56. int res = check(i);
  57. if (res > q){
  58. q = res;
  59. k = i;t = 0;
  60. }
  61. if (res == q)t++;
  62. }
  63. cout << q << ' ' << k << ' ' << t;
  64. return 0^0;
  65. }
Success #stdin #stdout 0.23s 5288KB
stdin
999000000 1000000000
stdout
512 999001080 1