## Editorial for Lũy thừa

Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Lưu ý: Các code mẫu dưới đây chỉ mang tính tham khảo và có thể không AC được bài tập này

#### Code mẫu của flashmt

var a,b:int64; j,k,i,t:longint;
t1,b1,k1:real;

begin
FOR i:=1 TO t DO
begin
b1:=b;
k1:=ln(b1)/ln(2);
k:=trunc(k1);
for j:=k downto 1 do
begin
t1:=exp(1/j*ln(b));
t1:=trunc(t1);
if exp(j*ln(t1))>=a then break;
end;
writeln('Case #',i,': ',j);
end;
end.


{$R+,Q+} const oo=1000000000000; max:array[1..40] of int64= (oo,1000000,10000,1000,252,100,52,32,22,16,13,10,9,8,7,6,6,5,5,4,4,4,4,4,4,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,2); var k,x,y:int64; test,t:longint; function power(x,k:int64):int64; var kq,m:int64; begin if k=0 then exit(1) else if k=1 then exit(x); m:=k div 2; kq:=power(x,m); kq:=kq*kq; if k mod 2=0 then exit(kq) else exit(kq*x); end; procedure solve; var l,r,mid,p:int64; kk:longint; begin for kk:=40 downto 1 do begin l:=1; r:=max[kk]+1; if kk=12 then begin write(''); end; repeat mid:=(l+r) div 2; p:=power(mid,kk); if (x<=p) and (p<=y) then begin k:=kk; exit; end; if p>y then r:=mid else l:=mid; until r-l<=1; end; end; begin readln(t); for test:=1 to t do begin readln(x,y); solve; writeln('Case #',test,': ',k); end; end.  #### Code mẫu của hieult #include <stdio.h> #include <math.h> main() { int n,c[10000],x2,y2,v; double a[10000],b[10000],x,y; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%lf",&a[i]); scanf("%lf",&b[i]); } for(int i=0;i<n;i++) { x=a[i]; y=b[i]; x2=0; y2=0; while(x>=1) { x=x/2; x2++; } while(y>=1) { y=y/2; y2++; } if(y2>x2) c[i]=y2-1; else { for(int j=y2-1;j>0;j--) { v=int(pow(b[i]+0.1,1./j)); if(a[i]<=pow(v,j)&&pow(v,j)<=b[i]) { c[i]=j; break; } } } } for(int i=0;i<n;i++) printf("Case #%d: %d\n",i+1,c[i]); }  #### Code mẫu của ll931110 {$N+}
{\$MODE DELPHI}
program POWER;
const
input  = '';
output = '';
maxk = 40;
eps = 0.00001;
var
fi,fo: text;
l,r: int64;
i,nTest: integer;

procedure openfile;
begin
assign(fi, input);
reset(fi);

assign(fo, output);
rewrite(fo);
end;

procedure solve;
var
i: integer;
t1,t2,k: extended;
s1,s2: int64;
begin
for i := maxk downto 1 do
begin
k := 1 / i;
t1 := exp(k * ln(l));
s1 := trunc(t1);
if t1 - s1 > eps then inc(s1);

t2 := exp(k * ln(r));
s2 := trunc(t2);

if s2 >= s1 then
begin
writeln(fo, i);
exit;
end;
end;
end;

procedure closefile;
begin
close(fo);
close(fi);
end;

begin
openfile;

for i := 1 to nTest do
begin
write(fo, 'Case #', i, ': ');
solve;
end;

closefile;
end.


#### Code mẫu của khuc_tuan

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
int st, t;
scanf("%d", &st);
for(t=1;t<=st;++t) {
long long L, R;
cin >> L >> R;
for(int k=40;k>=1;--k) {
long long left = 0, right = (long long)(pow( R, 1.0 / k) + 10);
while(left<right) {
long long mid = (left+right)/2;
long long z = 1;
for(int i=0;i<k;++i) {
z *= mid;
if(z>=L) break;
}
if(z>=L) right = mid;
else left = mid+1;
}
long long z = 1;
for(int i=0;i<k;++i) {
z *= left;
if(z>R) break;
}
if(L<=z && z<=R) {
printf("Case #%d: %d\n", t, k);
break;
}
}
}
//system("pause");
return 0;
}