简单数学题(水的不能在水的题了)

跟kuangbin聊过之后开始知道怎么做了,先刷着,慢慢就积累了,慢慢的就都会了,知识点也都会慢慢的积累的

先小小的试一下

big number

题目描述

In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of digits in the factorial of the number
题目描述

Input consists of several lines of integer numbers. The first line contains an integer n, which is the number of cases to be tested, followed by n lines, one integer 1 ≤ n ≤ 107 on each line.
题意:
就是求n的阶乘有多少位数
log(m*n)=log(m)+log(n)
然后(int)log10(n)+1就是这个数对应的位数
 

代码:

#include<iostream>
#include<cmath>
using namespace std;
double ju(int n){
 double sum=0;
 for(int i=1;i<=n;i++){
  sum+=log10(i);
 }
 return sum;
}
int main()
{
 int T,n;
 cin>>T;
 while(T--){
  cin>>n;
  cout<<(int)ju(n)+1<<endl;
 }
 return 0;

原文地址:https://www.cnblogs.com/ACWQYYY/p/4485752.html