11.26 求大数的位数

这道题用到的知道:
1.一个十进制数的位数等于log10x+1
2.对数相关的运算法则
比如求一个数的阶乘的位数,n!的位数:log(10)n! = log(10)(12345*…(n-2)(n-1)*n) = log(10)1+log(10)2+log(10)3+…log(10)n;
求T^T的位数:log10xx=x倍的log10x
下面为第二种的代码

#include <stdio.h>
#include <math.h>
int main()
{
    long long int a,b;
    double sum;
    while(scanf("%lld",&a)!=EOF){
            sum=a*log10(a);
        b=sum+1;
        printf("%lld\n",b);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43763889/article/details/84556228