-
Notifications
You must be signed in to change notification settings - Fork 0
/
A.cpp
53 lines (51 loc) · 950 Bytes
/
A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
long long power(long long x,long long y)
{
if(y==0)
return 1;
else
{
long long d=1,i;
for(i=0;i<y;i++)
d=d*x;
return d;
}
}
int main()
{
fastio;
long long t,i,a,b,p,mn,j;
cin>>t;
while(t--)
{
mn=0;
cin>>a>>b;
for(i=b;;i++)
{
if(i==1)
continue;
if(mn>0)
mn=p;
for(j=1;;j++)
{
if(power(i,j)>a)
{
p=j+i-b;
break;
}
}
//cout<<p<<" ";
if(mn==0)
{
mn=p;
}
else if(p>mn)
break;
//cout<<mn<<"\n";
}
cout<<mn<<"\n";
}
return 0;
}