hdoj-1018-Big Number
来源:互联网 发布:北邮网络教育登录系统 编辑:程序博客网 时间:2024/06/05 00:44
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
#include<stdio.h>#include<math.h>#define pi 3.1415926int main(){ int t,n,x; double a; scanf("%d",&t); while(t--) { scanf("%d",&n); a=(n*log(n)-n+0.5*log(2*pi*n))/log(10); x=int(a)+1; printf("%d\n",x); } return 0;}
求N!的位数
这道题其实知道公式很好做,我记得有个和lg有关的公式,这道题其实我想了半天,最后是学长告诉我用斯特林公式算的,不过斯特林公式好像是个近似
0 0
- HDOJ 1018 Big Number
- HDOJ 1018 Big Number
- hdoj 1018 Big Number
- HDOJ 1018 Big Number
- HDOJ 1018 Big Number
- hdoj 1018 Big Number
- HDOJ 1018 Big Number
- HDoj-1018-Big Number
- HDOJ Big Number 1018
- hdoj 1018 big number
- hdoj 1018 Big Number
- HDOJ 1018 Big Number
- hdoj-1018-Big Number
- HDOJ 1018 Big Number
- HDOJ 1018 Big Number
- HDOJ 1018 Big Number
- HDOJ 1018 Big Number
- hdoj 1018 Big Number
- 编辑文章 - 博客频道 - CSDN.NET
- c++中使用fstream读写文件
- 5-19 PAT Judge (25分)
- extract things from text files
- 安卓开发基础--打招呼(事件的简单处理)
- hdoj-1018-Big Number
- 5-20 电话聊天狂人 (25分)
- 迭代器模式和java集合Collection(二)HashMap和Set
- MVC、MVP、MVVM
- Java动态代理机制详解(JDK 和CGLIB,Javassist,ASM)
- C语言实现顺序表的插入、删除、查找、遍历等基本操作
- 发现群组(三)根据偏好聚类
- Windows下安装python问题汇总
- 5-21 Hashing (25分)