hdu Big Number 求一个数的位数
来源:互联网 发布:虚拟现实与大数据 编辑:程序博客网 时间:2024/06/05 08:06
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
2
10
20
Sample Output
7
19
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
2
10
20
Sample Output
7
19
阶乘的位数:
log10(1)+1=1;
log10(10)+1=2;
log10(100)+1=3;
等等;
由此规律来求阶乘的位数
代码:
#include<iostream>#include <algorithm>#include <string>#include <cstring>#include <cmath>using namespace std;int k;double x,y;int main(){int n,m,i,j; while(cin>>n){while(n--){ x=0;cin>>m;for(i=1;i<=m;i++) { x=x+log10(i); } k=x+1; cout<<k<<endl;}}return 0;}
0 0
- hdu Big Number 求一个数的位数
- HDU 1018 Big Number (log函数求数的位数)
- hdu 1018 Big Number (求一个数的阶乘的位数,公式!!!)
- Big Number(求阶乘数的位数)
- hdu 1018 -Big Number(求n的阶乘的位数)
- HDU 1018 Big Number(求n!的位数)
- Hdu 1018 Big Number 求N!的位数
- HDU 1018 Big Number(求n!的位数)
- hdu 1018 big number (求N!的位数)
- (hdu step 2.3.3)Big Number(求N!的位数)
- 求位数 hdu 1018 Big Number
- hdu-1018Big Number(阶乘求位数)
- hdu 1018 Big Number_Stirling数求N!的位数
- Big Number(求任意阶乘的位数)
- UVa1185 - Big Number(求阶乘的位数)
- 【HDU1018】Big Number - 求n!的位数
- hdu1018 Big Number(阶乘数的位数)
- HDU 1018 Big Number N!的位数
- OC_分类(Category)学习笔记
- Android获取RAM大小,内部存储大小,外部存储大小
- linux下printf实现不换行打印(printf显示不加换行的缓冲问题)
- 利用RMAN针对同平台下Oracle的实例进行异机迁移
- Hybrid app开发历程分享
- hdu Big Number 求一个数的位数
- linux 配置 ftp 服务器以及 ftp 客户端登录
- TCP协议封装格式及三次握手四次断开
- nyoj 整数划分(四) 746 (区间DP)
- vs2013 查看程序性能
- Swift下
- 基本数据类型 Int、Double、Float
- 移除 URL 中的 index.php
- 用 WEKA 进行数据挖掘,第 1 部分: 简介和回归