杭电1018-Big Number(大数)

AI权益加码!Claude Code、Cursor等20+工具免费用! 购周边限时加赠Coding Plan Lite,畅享主流AI工具!学习进阶更高效! 阅读详情

Big Number

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 31165    Accepted Submission(s): 14464


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 ≤ 10 7 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
 

         还记得那个神奇的 斯塔林公式吗?


         直接就是公式了!


#include<cstdio>
#include<cstring>
#include<cmath>
#define pi acos(-1.0)
using namespace std;
int n;
int solve()
{
	return (int)((n*log(n)-n+(log(2*pi*n))/2)/log(10))+1;
}
int main()
{
	int N;
	scanf("%d",&N);
	while(N--)
	{
		scanf("%d",&n);
		int t=solve();
		printf("%d\n",t);
	}
	return 0;
}


杭电 online judge 1018Big Number 杭州电子科技学 online judge 1018 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... 阅读详情

相关推荐

杭电1018Big 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 dig

漠宸离若的博客 477

杭电1212 Big Number (大数求模运算)

Big NumberTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5846 Accepted Submission(s): 4086Problem DescriptionAs we know, Big Number is alwa

一个不知名码农的专栏 806

Big number

题目;Problem DescriptionIn 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

446

杭电oj--1018 Big Number

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 h

yiyuqingning的博客 395

杭电ACM1018BigNumber解析

一开始看见这道题目不是很明白到底是什么意思,搞了好久才明白是:给一个数规定输入数字的个数,案例中给出了2也就是输入2个数,输入的这两个数求它的阶乘的位数,一开始想着是这样做:直接求指出然后求长度,这是最不需要动脑子的方法,但是,这个方法并不奏效,因为阶乘的数值是很的,普通的int,long类型一旦求比较的数的阶乘的时候往往会溢出,所以最好的方法应该是避免求他的值才行。

王洋的专栏 3668

杭电OJ【1018Big Number 大数阶乘位数

思路分析: 求大数阶乘位数问题,如果n较的时候,n!必然是一个很的数。 任意一个数a的位数等于long10(a)+1 推导过程如下: 如果 10^(x-1) 则 ln(10^(x-1)) 所以a的位数是(int)ln(a)+1。 假设A=n!=1*2*3*……*n=(int)ln(1*2*3*……*n)+1=(int)(ln(1)+ln(2)+ln(3)+……+ln(n)

戦う! 288

杭电ACM OJ 1018 Big Number 两数相乘出一个大数,求大数的位数 注意log的使用

Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 39368    Accepted Submission(s): 19166 Problem Description In many appli

qq_36523667的博客 621

杭电oj HDOJ 1018 Big Number(斯特林公式求大数阶乘的位数)

杭电oj HDOJ 1018 Big Number 题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1018 Problem Description In many applications very large integers numbers are required. Some of these applications are using ke...

qq_39880604的博客 284

杭电oj1018Big Number

杭电oj1018Big 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 t...

qq_35225958的博客 385

杭电1018

杭电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):17850    Accepted S

fk961859482的专栏 917

杭电1018-Big Number

Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 20623    Accepted Submission(s): 9261 Problem Description In many applicat

ecjtu_acm_菜鸟—鱼尾尾 1064

HDOJ 1018 Big Number

来源: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): 22074    Accepted Submission(

MummyDing's Blog 1471

杭电1018 BIG NUMBER

杭电1018 BIG NUMBER阶乘的位数 这题要求n的阶乘的位数,如果n较时,n的阶乘必将是一个 很的数,题中说1<=n<10000000,当n=10000000时可以说n 的阶乘将是一个非常巨数字,对于处理大数的问题,我 们一般用字符串,这题当n取最值时,就是一千万个数字相 乘的积,太了,就算保存在字符串中都有一点困难,而且 一千万个数字相乘是会涉及到大数的乘法,

qq_25354711的博客 309

杭电ACM 1018 Big Number

http://acm.hdu.edu.cn/showproblem.php?pid=1018 题意是求一个数的阶乘之后得数的位数。 简单一点的话,如果要求的数很小的话,简单的递归算出阶乘,然后数数位数就可以,以下: #include #include #include using namespace std; long Fac(int); int main(){ int a; cin

GinSmile的博客 3036

杭电 1018 Big Number

Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 17850    Accepted Submission(s): 8006 Problem Description In many applicat

追随大神的脚步 1185

杭电OJ——1018 Big number

Big Number    Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/32768 K (Java/Others) Problem Description In many applications very large integers numbers are required. Some o

李树花开,风中摇曳 3615
上一篇: 求N!的位数(斯特林公式)
下一篇: poj2506-Tiling(规律,大数)
Eric_keke
博客等级 码龄12年 37粉丝 221原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值