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): 41932    Accepted Submission(s): 20544

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
题目大意:求阶乘位数,数据很大。
题目分析:斯特林公式   X的阶乘位数==llog10(1)+log10(2)+···+long10(n)取整后加1
 #include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
double sum=1.0;
scanf("%d",&n);
for(double i = ; i <= n ;i++)
{
sum+=log10(i);
}
cout << (long)sum << endl;
}
return ;
}
 

【HDOJ1018】【大数阶乘位数】【斯特林公式】的更多相关文章

  1. nyoj___大数阶乘

    http://acm.nyist.net/JudgeOnline/problem.php?pid=28 大数阶乘 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描述 我们都知 ...

  2. 大数阶乘 nyoj

    大数阶乘 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 我们都知道如何计算一个数的阶乘,可是,如果这个数很大呢,我们该如何去计算它并输出它?   输入 输入一个整数 ...

  3. 大数阶乘(c++实现)

    #include <iostream>using namespace std;#define N 1000int BigNumFactorial(int Num[], int n);voi ...

  4. nyist28大数阶乘

    http://acm.nyist.net/JudgeOnline/problem.php?pid=28 大数阶乘 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 我们 ...

  5. 大数阶乘(c语言)

    大数阶乘.代码比较简单. #include<stdio.h> #include<string.h> #define MAXN 25000 // 如果你的阶乘N比较大,建议大一点 ...

  6. 【大数阶乘】NYOJ-28

    大数阶乘 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 我们都知道如何计算一个数的阶乘,可是,如果这个数很大呢,我们该如何去计算它并输出它?   输入 输入一个整数 ...

  7. HDU 1018(阶乘位数 数学)

    题意是求 n 的阶乘的位数. 直接求 n 的阶乘再求其位数是不行的,开始时思路很扯淡,想直接用一个数组存每个数阶乘的位数,用变量 tmp 去存 n 与 n - 1 的阶乘的最高位的数的乘积,那么 n ...

  8. 【ACM】大数阶乘 - Java BigInteger实现

    大数阶乘 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 我们都知道如何计算一个数的阶乘,可是,如果这个数很大呢,我们该如何去计算它并输出它?   输入 输入一个整数 ...

  9. HDU 1133 Buy the Ticket (数学、大数阶乘)

    Buy the Ticket Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...

随机推荐

  1. POJ 2456 Agressive cows(二分)

    POJ 2456 Agressive cows 农夫 John 建造了一座很长的畜栏,它包括N (2≤N≤100,000)个隔间,这 些小隔间的位置为x0,...,xN-1 (0≤xi≤1,000,0 ...

  2. (Java学习笔记) Java Networking (Java 网络)

    Java Networking (Java 网络) 1. 网络通信协议 Network Communication Protocols Network Protocol is a set of rul ...

  3. Java 中的代理模式及动态代理

    原文:https://blog.csdn.net/briblue/article/details/73928350

  4. freemarker中的null异常处理以及!与??的使用(转)

    原文链接: https://blog.csdn.net/mexican_jacky/article/details/50638062 阅读数:6304 如工程包含: 在user中我们有个角色,那么我们 ...

  5. ubuntu 安装pptp

    1.安装PPTP服务器 更新软件 apt-get update 安装pptpdapt-get install pptpd 2.配置PPTP服务器 用 vi 编辑/etc/pptpd.conf查找如下内 ...

  6. sac cut

    Put a perl script here in order to remind myself of its correct usage:

  7. POJ 2407 Relatives(欧拉函数入门题)

    Relatives Given n, a positive integer, how many positive integers less than n are relatively prime t ...

  8. Oracle 定时器

    我的代码 declare job number; begin dbms_job.submit( JOB=>job, what=>'addBytime;',// 这里要写分号,不然容易出错. ...

  9. 解析url中参数

    兼容不带参数等情况 function getUrlParam(){ var params = {}; var search = location.search; search = /\?/.test( ...

  10. js 数组去重的几种方式及原理

    let arr = [1,1,'true','true',true,true,15,15,false,false, undefined,undefined, null,null, NaN, NaN,' ...