[BZOJ3000]Big Number(斯特林公式)】的更多相关文章

求n!在k进制下的位数,n<=1e18 斯特林公式:$n!\approx \sqrt{2\pi n}(\frac{n}{e})^n$ 在n很大的时候有较好的精度保证. $\log_{k}n!+1=\frac{1}{2}\frac{\ln(2\pi n)}{\ln k}+n\frac{\ln n-\ln e}{\ln k}+1$ n较小时直接暴力求解即可. #include<cmath> #include<cstdio> #include<algorithm> #d…
Description 给你两个整数N和K,要求你输出N!的K进制的位数. Input 有多组输入数据,每组输入数据各一行,每行两个数——N,K Output 每行一个数为输出结果 Sample Input 2 52 1010 10100 200 Sample Output 11769对于100%的数据,有2≤N≤2^31, 2≤K≤200,数据组数T≤200. 题解 用Stirling公式求近似值 位数=logk(n!)+1 ≍ logk(sqrt(2πn)*(n/e)^n)+1 = logk…
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…
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 facto…
Big Number 题意:算n!的位数. 题解:对于一个数来算位数我们一般都是用while去进行计算,但是n!这个数太大了,我们做不到先算出来在去用while算位数. while(a){ cnt++; a/=; } 将一个数对取10对数(取整),然后再加一就是这个数的位数,然后我们在算n!的时候每次对10取对数就好了. #include<iostream> #include<cmath> using namespace std; int main() { ios::sync_wi…
由Stirling公式: $$n! \approx \sqrt{2 \pi n} (\frac{n}{e})^n$$ 故:$$\begin{align} ans &= log_k n! + 1 \\ &\approx log_k [\sqrt{2 \pi n} (\frac{n}{e})^n] + 1 \\ &= \frac{1}{2} log_k 2 \pi n + n * (log_k n - log_k e) + 1\\ \end {align}$$ 又$log_a b =…
Description 给你两个整数N和K,要求你输出N!的K进制的位数. Input 有多组输入数据,每组输入数据各一行,每行两个数——N,K Output 每行一个数为输出结果. Sample Input 2 5 2 10 10 10 100 200 Sample Output 1 1 7 69 HINT 对于100%的数据,有2≤N≤2^31, 2≤K≤200,数据组数T≤200. Source Solution 安利一个高深的公式:Stirling公式 用这个公式,当n较大时很精确,而且…
Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 37482    Accepted Submission(s): 18009 Problem Description In many applications very large integers numbers are required. Some of these…
Big Number Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 27027   Accepted: 8626 Description In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encry…
Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 40262    Accepted Submission(s): 19637 Problem Description In many applications very large integers numbers are required. Some of these…