HDU-1018 BigNumber(斯特林近似)

题目链接

斯特林近似求数位长度经典题,更新板子顺手切了

#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#define DBG(x) cerr << #x << " = " << x << endl;
const double PI = acos(-1.0);
using namespace std;

int t,n;

int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        printf("%d\n",(int)((0.5*log(2*PI*n)+n*log(n)-n)/(log(10)))+1);
    }
    return 0;
}

  

原文地址:https://www.cnblogs.com/DuskOB/p/10009215.html

时间: 2024-11-19 19:14:34

HDU-1018 BigNumber(斯特林近似)的相关文章

HDU 1018 Big Number (简单数学)

Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 25649    Accepted Submission(s): 11635 Problem Description In many applications very large integers numbers are required. Some of these

HDU 1018 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 the number of

1130 N的阶乘的长度 V2(斯特林近似)

1130 N的阶乘的长度 V2(斯特林近似)(51NOD基础题) 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 输入N求N的阶乘的10进制表示的长度.例如6! = 720,长度为3. Input 第1行:一个数T,表示后面用作输入测试的数的数量.(1 <= T <= 1000) 第2 - T + 1行:每行1个数N.(1 <= N <= 10^9) Output 共T行,输出对应的阶乘的长度. Input示例 3 4 5 6 Output示例 2 3

HDU 1018 Big Number (数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1018 解题报告:输入一个n,求n!有多少位. 首先任意一个数 x 的位数 = (int)log10(x) + 1; 所以n!的位数 = (int)log10(1*2*3*.......n) + 1; = (int)(log10(1) + log10(2) + log10(3) + ........ log10(n)) + 1; 1 #include<cstdio> 2 #include<cs

HDU 1018 Big Number 斯特林数近似n!

题目链接:点击打开链接 斯特林数:点击打开链接 题意是计算n! 的位数 即ans = log10(n!) = log10(sqrt(2πn)) + n*log10(n/e) #include <stdio.h> #include <iostream> #include <algorithm> #include <sstream> #include <stdlib.h> #include <string.h> #include <

HDU 1018(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1018 Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 27548    Accepted Submission(s): 12526 Problem Description In many applications ve

HDU 1018 -- Big Number (Stirling公式求n!的位数)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1018 Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 40551    Accepted Submission(s): 19817 Problem Description In many applications ver

hdu 3625 第一类斯特林数

题目链接:click here Examining the Rooms Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1146    Accepted Submission(s): 689 Problem Description A murder happened in the hotel. As the best detective

HDU 1018

题意:求n!的位数 题解:斯特林数: log10(n!)=1.0/2*log10(2*pi*n)+n*log10(n/e). 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <math.h> 5 #define E 2.71828182 6 #define PI acos( -1.0 ) 7 8 int n; 9 10 int main() 11 { 12