fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve(){
  5. long long a;
  6. long long b;
  7. cin>>a>>b;
  8. int cnt = 0;
  9.  
  10. if(a < b){
  11. cout<<'1'<<endl;
  12. return;
  13. }
  14. // cout << a<<b;
  15.  
  16. long long tempa =a;
  17. long long tempb =b;
  18. // cout<<"step1"<<endl;
  19.  
  20. while(tempa >0){
  21. tempa = tempa / tempb;
  22. cnt++;
  23. // cout << tempa;
  24. if(tempa == a && cnt > 20){
  25. cnt = 1;
  26. tempb++;
  27. }
  28.  
  29. }
  30.  
  31. cout<<cnt<<endl;
  32.  
  33. }
  34. int main() {
  35. int t;
  36. cin>>t;
  37. while(t--){
  38. solve();
  39. }
  40. return 0;
  41. }
Success #stdin #stdout 0s 5320KB
stdin
6
9 2
1337 1
1 1
50000000 4
991026972 997
1234 5678
stdout
4
12
2
13
3
1