//求阶乘的位数

//方法:使用10的对数解决
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
 int count;
 cin>>count;
 while(count--)
 {
  int number;
  cin>>number;
  double sum = 0;
  for(int i = 1;i<number+1;i++)
  {
   sum+=log10((double)i);
  }
  //注意不要使用floor,否则会出现结果错误的情况
  cout<<(int)(sum+1)<<endl;
 } 
 return 0;
}

相关文章:

  • 2021-08-19
  • 2021-05-05
  • 2021-11-13
  • 2021-07-31
  • 2021-04-27
  • 2021-04-26
  • 2021-07-12
  • 2021-09-26
猜你喜欢
  • 2021-07-03
  • 2021-07-04
  • 2021-06-19
  • 2021-12-10
  • 2022-01-10
  • 2021-12-14
  • 2021-04-04
相关资源
相似解决方案