提交时间:2025-10-18 14:28:53

运行 ID: 38645

#include<bits/stdc++.h> #define int long long #define fir first #define sec second using namespace std; const int S=5500,E=57,INF=1e9; map<int,int> Dis,IQ; int w[E],X[S],D[S]; int Len; inline void Init(){ for(int i=2;i<=54;i++)w[i]=floorl(powl(i,8.0/7)); queue<int> q; Dis[1]=1,IQ[1]=1,q.push(1); while(!q.empty()){ int u=q.front();q.pop(); IQ[u]=0; for(int i=2;i<=54&&INF/i/i>=u;i++){ int v=u*i*i; if(!Dis.count(v)||Dis[u]*w[i]>Dis[v]){ Dis[v]=Dis[u]*w[i]; if(!IQ.count(v)||!IQ[v])IQ[v]=1,q.push(v); } } }for(auto it=Dis.begin();it!=Dis.end();it++){ X[++Len]=(*it).fir; D[Len]=max(D[Len-1],(*it).sec); } } int x,y; inline void slv(){ cin>>x>>y; int Pos=upper_bound(X+1,X+Len+1,y/x)-X-1; cout<<D[Pos]<<endl; } signed main(){ #ifndef ONLINE_JUDGE freopen("biggraph.in","r",stdin); freopen("biggraph.out","w",stdout); #endif Init(); int q;cin>>q; while(q--)slv();return 0; }