M
来源:互联网 发布:猎场小说剧情介绍 知乎 编辑:程序博客网 时间:2024/04/29 10:40
Big Number
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 38406 Accepted Submission(s): 18599
Problem Description
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
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.
Output
The output contains the number of digits in the factorial of the integers appearing in the input.
Sample Input
21020
Sample Output
719
Source
Asia 2002, Dhaka (Bengal)
Recommend
JGShining
(题目来源于http://acm.hdu.edu.cn/showproblem.php?pid=1018)
解题思路:
运用取对数思想:
举一个简单的例子,100有多少位,3位。log10(100)=2;2+1=3;
log10(976)=2.9894;加1后等于3.984,取int后为3;
需要有的知识:
1、log和log10在头文件<math.h>,在c++中也可以用<cmath>
2、double log( double x );(以e为底)
double log10( double x );
扩展知识:
1、如何表示以其他数为底的数字呢,例如log3(x)
运用换底公式即可,log3(x)=ln(x)/ln(3)或者log(x)/log(3);
代码展示:
(题目来源于http://acm.hdu.edu.cn/showproblem.php?pid=1018)
解题思路:
运用取对数思想:
举一个简单的例子,100有多少位,3位。log10(100)=2;2+1=3;
log10(976)=2.9894;加1后等于3.984,取int后为3;
需要有的知识:
1、log和log10在头文件<math.h>,在c++中也可以用<cmath>
2、double log( double x );(以e为底)
double log10( double x );
扩展知识:
1、如何表示以其他数为底的数字呢,例如log3(x)
运用换底公式即可,log3(x)=ln(x)/ln(3)或者log(x)/log(3);
代码展示:
#include<iostream>#include<cmath>using namespace std;int main(){int n=0;while(cin>>n){while(n--){int m=0;double sum=0;cin>>m;for(;m>=2;m--){sum=sum+log10(m);}cout<<(int)sum+1<<endl;}}}
阅读全文
0 0
- M
- m
- m,
- m
- m
- M
- ^M
- M
- m
- M
- M
- M
- M
- (?m)
- (?m)
- M
- M
- M
- ELK之logstath的使用(3)----filter插件的使用
- AndroidStudio 基础配置总结
- Chrome 控制台实用指南
- 心得(2017-8)
- 安卓的elevation、以及Z值等
- M
- 使用vmware虚拟机安装OS X 10.11
- C/C++ 文件读写操作总结
- Rxjava2 flatMap实现注册并登录的案例
- Android Studio系列教程六--Gradle多渠道打包
- Android程序员学WEB前端(8)-CSS(3)-盒子内联块级定位浮动-Sublime
- 插入排序之--折半插入排序
- 浅谈Android嵌入式状态栏的开发
- spring boot