Light oj 1045 Digits of Factorial Solution

 problem link  : Light oj 1045

Explain: We know that 10 base number system digit of x number is  =

log10x+1

According to the same way  b base number system digit of x number is =  
logbx+1

Accoding to the logarithm law:

   We know    
                               



   is the answer 



///La ilaha illellahu muhammadur rasulullah

///******Bismillahir-Rahmanir-Rahim******///

///Abul Hasnat  Tonmoy

///Department of CSE,23rd batch

    ///Islamic University,Bangladesh

    Solution in c++:

    #include <bits/stdc++.h>
    using namespace std;
    double v[1000000];
    int main()
    {
        long long  int t,b,i,j,k,r,n;
        for(int i=1; i<=1000000; i++)
            v[i]=v[i-1] + log(i);
        cin>>t;
        for(k=1; k<=t; k++)
        {
            cin>>n>>b;
            r=v[n]/log(b);
            printf("Case %d: %lld\n", k,r+1);
        }
        return 0;
    }






    No comments

    Most View Post

    Recent post

    Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

      Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

    Powered by Blogger.