原题链接:Problem - A - Codeforces

题意:找一个范围内质因子最多的数,范围

思路

正统思路与证明

For a specific , Piggy always chooses such that is a prime number, so the score is the number of prime factors of . It is easy to see that the number with at least prime factors is . The largest integer satisfying is . Also, because , then , so , hence . So the answer is . Time complexity: or per test case.

实现

#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 40;
typedef long long LL;
 
int t;
LL a[N];
 
int main()
{
    cin >> t;
    for(int i = 0 ; i < 40; i ++)
        a[i] = 1 << i;
 
    /* while( t --)
    {
        int l, r;
        cin >> l >> r;
 
        int x = 0, y = 40;
        
        while(x < y)
        {
            int mid = x + y + 1 >> 1;
            if(a[mid] > r) y = mid - 1;
            else x = mid;
        }
 
        cout << x << endl;
    } */
 
    while(t --)
    {
        int l, r;
        cin >> l >> r;
 
        cout << __lg(r) << endl;
    }
}