hdu1018】的更多相关文章

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1018 题意:求n!的数位(即n!有多少位): 思路:对于一个数x,它的数位ans=log10(x): 证明:假设pow(10, y-1) <= x < pow(10, y)-----1,显然有ans(x)=y: 由1式可得 y-1 <= log10(x) < y: 所以 ans(x) = (int) log10(x) + 1: 此题中代入 x = n! = 1*2*3....*n, 可…
可以用斯特林公式直接求出n!的结果. 当n较小时公式已经很准确了,所以可以使用.但是,对于这种极限值为1的公式,只能用来估计位数,不能作为严格的等于的公式.类似的有素数分布定理  x/ln(x)~f(x),注:f(x)表示1 ,2, 3,...,x中素数的个数. # include <cstdio> # include <cmath> #include<iostream> using namespace std; int main() { int T, n; cin&g…
Big Number 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 th…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1018 题目大意: 求n阶乘的位数思路: N的阶乖的位数等于LOG10(N!)=LOG10(1)+.....LOG10(N) 这里的解应该对上述结果向上取整 一开始直接输出cout<<ceil(ans)<<endl;这样出错,是因为ceil的返回值是double类型的,这里应该强制转化成(int)后输出就不会错了 还可以用斯特林公式 #include<iostream> #…
题目链接 斯特林近似求数位长度经典题,更新板子顺手切了 #include <cstdio> #include <cmath> #include <cstring> #include <iostream> #include <algorithm> #define DBG(x) cerr << #x << " = " << x << endl; const double PI = a…
Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 31681    Accepted Submission(s): 14769 Problem Description In many applications very large integers numbers are required. Some of these…
Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 37732    Accepted Submission(s): 18174 Problem Description In many applications very large integers numbers are required. Some of these…
杭电上面1018>>点击测试<< 思路:当问到阶乘的值时候,用万进制来写:但是问阶乘值的位数的时候,就可以用斯特林公式了 log10(2*pi*n)/2+n*log10(n/e)+1 注意cmath中log()和log10()的使用; #include<cstdio> #include<cmath> #include<iostream> using namespace std; #define PI 3.14159265 int main() {…
Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 38450    Accepted Submission(s): 18633 Problem Description In many applications very large integers numbers are required. Some of thes…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1141 题意:××公司是制造computer的,1960年它造的computer是4bit的,之后每10年翻倍: 有一个衡量computer的标准,就是它最大可以存下n!(无符号位),那么它就是n级: 求x年时该公司的电脑为几级(1960<= x <=2160): 思路:2160年时computer是4×pow(2, 20)=4194304bit,那么能储存的最大数大概为pow(2, 4194304…