fork download
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4. #include <ext/rope>
  5. using namespace __gnu_cxx;
  6. using namespace std;
  7. using namespace __gnu_pbds;
  8. using ll = long long;
  9. typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> yam; // find_by_order, order_of_key
  10. using namespace std;
  11. #define moe \
  12. ios::sync_with_stdio(0); \
  13. cin.tie(0); \
  14. cout.tie(0); \
  15. cout << setiosflags(ios::fixed) << setprecision(9);
  16. #define all(a) (a).begin(), (a).end()
  17. #define allr(a) (a).rbegin(), (a).rend()
  18. #define pb push_back
  19. #define f(i, n, m) for (ll i = (n); i < (ll)(m); i++)
  20. #define rf(i, n, m) for (ll i = (ll)(m) - 1; i >= (ll)(n); i--)
  21. #define no cout << "NO" << "\n";
  22. #define yes cout << "YES" << "\n";
  23. const ll MOD = 1e9 + 7;
  24. #define vll vector<ll>
  25. #define vpll vector<pair<ll, ll>>
  26. const ll sup = 1e18;
  27. const ll inf = -1e18;
  28. #define bob cout << "BOB" << "\n";
  29. #define alice cout << "ALICE" << "\n";
  30. map < ll , ll > mp ;
  31.  
  32. vector<ll> sieve(ll n) {
  33. vector<ll> primes(n + 1, 1);
  34. primes[0] = primes[1] = 0;
  35. mp[0] = 1 ; mp[1] = 1 ;
  36. for (ll i = 2; i * i <= n; i++) {
  37. if (primes[i]) {
  38. mp[i] = 1 ;
  39. for (ll j = i * i; j <= n; j += i) {
  40. primes[j] = 0;
  41. mp[j]++;
  42. }
  43. }
  44. }
  45. vector<ll> prime_numbers;
  46. for (ll i = 2; i <= n; i++) {
  47. if (primes[i]) prime_numbers.pb(i);
  48. }
  49. return prime_numbers;
  50. }
  51. void solve() {
  52.  
  53.  
  54.  
  55. }
  56.  
  57. /*struct DSU {
  58.   vll p, sz;
  59.   ll max_comp;
  60.   DSU(ll n) {
  61.   p.resize(n);
  62.   sz.assign(n, 1);
  63.   max_comp = 1;
  64.   f(i, 0, n) p[i] = i;
  65.   }
  66.   ll ufind(ll x) { return (p[x] == x) ? x : (p[x] = ufind(p[x])); }
  67.   bool unite(ll x, ll y) {
  68.   x = ufind(x), y = ufind(y);
  69.   if (x == y) return false;
  70.   if (sz[x] < sz[y]) swap(x, y);
  71.   p[y] = x;
  72.   sz[x] += sz[y];
  73.   max_comp = max(max_comp, sz[x]);
  74.   return true;
  75.   }
  76. };*/
  77.  
  78. signed main() {
  79. moe;
  80. vector<int> my_table(1e6+1,0);
  81. map<int,vector<int>> scores;
  82. scores[0]={0,1};
  83. for (int i=2;i<=1e6;i++) {
  84. if (my_table[i]==0) {
  85. my_table[i]=1;
  86. for (int j=i*2;j<=1e6;j+=i) {
  87. my_table[j]++;
  88. }
  89. }
  90. scores[my_table[i]].push_back(i);
  91. }
  92. int p=1;
  93. while (p<10e6) {
  94. p*=2;
  95. }
  96. vector<int> arr(p*2,0);
  97. for (int i=0;i<1e6+1;i++) {
  98. arr[i+p]=my_table[i];
  99. }
  100. for (int i=p-1;i>0;i--) {
  101. arr[i]=max(arr[i*2],arr [i*2+1]);
  102. }
  103.  
  104.  
  105.  
  106. ll hoh = 1;
  107. cin >> hoh;
  108.  
  109. while (hoh--) {
  110. /*ll n,m;cin>>n>>m;ll ct=0;
  111.   vector<vector<char>>g(n,vector<char>(m));
  112.   f(i,0,n)f(j,0,m) {
  113.   cin>>g[i][j];
  114.   if (g[i][j]=='*')ct++;
  115.   }
  116.   DSU dsu(n*m);
  117.   f(i,0,n) {
  118.   f(j,0,m) {
  119.   if (g[i][j]!='.')continue;
  120.   if (i-1>=0) {
  121.   ll nwi=i-1;
  122.   if (g[nwi][j]=='.')dsu.unite(nwi*m+j,i*m+j);
  123.   }
  124.   if (i+1<=n-1) {
  125.   ll nwi=i+1;
  126.   if (g[nwi][j]=='.')dsu.unite(nwi*m+j,i*m+j);
  127.   }
  128.   if (j-1>=0) {
  129.   ll nwj=j-1;
  130.   if (g[i][nwj]=='.')dsu.unite(i*m+nwj,i*m+j);
  131.   }
  132.   if (j+1<=m-1) {
  133.   ll nwj=j+1;
  134.   if (g[i][nwj]=='.')dsu.unite(i*m+nwj,i*m+j);
  135.   }
  136.   }
  137.   }
  138.   vll ans(ct);
  139.   ll curr=0;
  140.   f(i,0,n) {
  141.   f(j,0,n) {
  142.   if (g[i][j]=='*') {
  143.   if (i-1>=0) {
  144.   ll nwi=i-1;
  145.   dsu.unite(nwi*m+j,i*m+j);
  146.   }
  147.   if (i+1<=n-1) {
  148.   ll nwi=i+1;
  149.   dsu.unite(nwi*m+j,i*m+j);
  150.   }
  151.   if (j-1>=0) {
  152.   ll nwj=j-1;
  153.   dsu.unite(i*m+nwj,i*m+j);
  154.   }
  155.   if (j+1<=m-1) {
  156.   ll nwj=j+1;
  157.   dsu.unite(i*m+nwj,i*m+j);
  158.   }
  159.   }
  160.   ll rec=dsu.ufind(m*i+j);
  161.   cout<<dsu.sz(rec)<<endl;
  162.   }
  163.   }
  164.   */
  165. int l,r;
  166. cin>>l>>r;
  167. if (r==1) {
  168. cout<<1<<" "<<1<<endl;
  169. continue;
  170. }
  171.  
  172. int l1=l,r1=r;
  173. l+=p;
  174. r+=p;
  175. int maxi=0;
  176. while (r>=l && r>0) {
  177. if (l%2==1)maxi=max(maxi,arr[l++]);
  178. if (r%2==0)maxi=max(maxi,arr[r--]);
  179. l/=2;
  180. r/=2;
  181.  
  182. }
  183. auto it = lower_bound(all(scores[maxi]) , l1 ) ;
  184. int counter = *it ;
  185.  
  186. /* int counter=scores[maxi].size()-1;
  187.   for (int i=scores[maxi].size()/2;i>0;i/=2) {
  188.   while (counter-i>=0 &&scores[maxi][counter-i]>=l1)counter-=i;
  189.   }*/
  190. ll answer=counter;
  191. /*auto it = upper_bound(all(scores[maxi]) , r) ;
  192.   ll ans = 0 ;
  193.   if (it == scores[maxi].end() ) {
  194.   ans = *scores[maxi].rbegin() ;
  195.   }
  196.   else {
  197.   it = prev(it) ;
  198.   ans = *it ;
  199.   }*/
  200. //cout<<maxi<<endl;
  201. ll res=(1ll<<(maxi-1));
  202. cout <<answer<<" "<<res<<endl;
  203.  
  204.  
  205.  
  206. }
  207.  
  208. return 0;
  209. }
  210.  
  211.  
  212.  
Success #stdin #stdout 0.08s 143012KB
stdin
Standard input is empty
stdout
0 -9223372036854775808