Anik_Akash

dig

Jan 24th, 2021
822
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace    std;
  3.  
  4.  
  5. typedef long long int       ll;
  6. typedef double              dl;
  7. typedef unsigned long long  ul;
  8.  
  9. const int MX = 1e6+5;
  10.  
  11.  
  12.  
  13. int main()
  14. {
  15.    #ifndef ONLINE_JUDGE
  16.        freopen("input.txt","r",stdin);
  17.        freopen("out.txt","w",stdout);
  18.    #endif
  19.    
  20.        vector<dl>v(MX);
  21.  
  22.        for(int i=1; i<MX; i++)
  23.         {
  24.             v[i] = v[i-1]+log10(i);
  25.         }
  26.  
  27.    int t;
  28.    cin>>t;
  29.    int x=1;
  30.    while(t--);
  31.    {
  32.         int n,b;
  33.         cin>>n>>b;
  34.  
  35.         int digit = v[n] / (log10(b))+1;
  36.        
  37.         cout<<"Case "<<x++<<": "<<digit<<endl;
  38.    }
  39.     return 0;
  40. }
  41. /// ----------------------------Funaction Descriptions----------------------------------//
  42.  
  43.  
  44. //author anikaksh;
RAW Paste Data