
hdu——Big Number
发布日期:2022-02-02 02:58:03
浏览次数:1
分类:技术文章
本文共 1046 字,大约阅读时间需要 3 分钟。
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
21020
Sample Output
719
题目是要求出n!的位数,用到了斯特林数:
log10(n!)=1.0/2*log10(2*pi*n)+n*log10(n/e)
分析:
#include#include const double PI=3.14159265;using namespace std;int main(){
int t,n;
double sum;
cin>>t;
while(t--)
{
cin>>n;
sum=(n*log(n) - n + 0.5*log(2*n*PI))/log(10)+1;
cout<<(int)sum<
}
return 0;}
转载地址:https://blog.csdn.net/u010368749/article/details/12715123 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
表示我来过!
[***.36.148.179]2022年06月18日 11时40分08秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
最新文章
ORALCE用户管理
2019-12-13 02:35:50
三范式讲解
2019-12-13 02:35:50
django csrf解决办法
2019-12-13 02:35:50
c++模板学习一
2019-12-13 02:35:50
因为热爱,所以选择!
2019-12-13 02:35:50
JSON介绍
2019-12-13 02:35:51
数据缓存
2019-12-13 02:35:51
Foundation构架秘籍
2019-12-13 02:35:51
在使用poi的时候找不到方法的解决办法
2019-12-13 02:35:49
vue 开发命名规范
2019-12-13 02:35:49
vue全局组件自动注册,无需再单独引用
2019-12-13 02:35:49
关于james邮箱服务器配置、维护以及常见问题定位
2019-12-13 02:35:49
ORA-01843的错误.这个错误代表无效的月份一般在日期转化的时候会提示
2019-12-13 02:35:49
透视图切换
2019-12-13 02:35:47
jQuery获取iframe内的DOM对象
2019-12-13 02:35:47
你会做Web上的用户登录功能吗?
2019-12-13 02:35:47
隐藏文件的好方法
2019-12-13 02:35:48
ie和火狐都兼容的背景图片设置方式
2019-12-13 02:35:48
设计一个html布局器,能移动。拖拽,有属性框。并能生成页面
2019-12-13 02:35:48
JS 文件压缩与反压缩
2019-12-13 02:35:48