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 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
 
Source
 
/**
题目:Big Number
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1018
题意:求n!的位数。
思路:
斯特林公式:LL res=(long)( (log10(sqrt(4.0*acos(0.0)*n)) + n*(log10(n)-log10(exp(1.0)))) + 1 );
注意:当n=1的时候,公式不成立。自己算。 */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
const int mod=1e9+;
const int maxn=1e6+;
int T, n;
int main()
{
cin>>T;
while(T--)
{
scanf("%d",&n);
if(n==){
printf("1\n"); continue;
}
LL res=(long)( (log10(sqrt(4.0*acos(0.0)*n)) + n*(log10(n)-log10(exp(1.0)))) + );
printf("%lld\n",res);
}
return ;
}

hdu1018 Big Number 斯特林公式 求N!的位数。的更多相关文章

  1. 求N!的位数

    #include<iostream> #include <cstdio> #include <cmath> using namespace std; const d ...

  2. c# 求第30位数的值

    1,1,2,3,5,8,13,21,34,55.... 求第30位数的值: 递归方法: class Program { static void Main(string[] args) { //找规律: ...

  3. C语言 · 递归求二进制表示位数

    算法训练 6-2递归求二进制表示位数   时间限制:10.0s   内存限制:256.0MB      问题描述 给定一个十进制整数,返回其对应的二进制数的位数.例如,输入十进制数9,其对应的二进制数 ...

  4. 蓝桥杯 算法训练 ALGO-151 6-2递归求二进制表示位数

    算法训练 6-2递归求二进制表示位数   时间限制:10.0s   内存限制:256.0MB 问题描述 给定一个十进制整数,返回其对应的二进制数的位数.例如,输入十进制数9,其对应的二进制数是1001 ...

  5. nefu26(求数的位数)

    Description 根据密码学需要,要计算某些数的阶乘的位数. Input 第一行为整数n ,接下来 n 行, 每行1个数m (1 ≤ m ≤ 10^7) . Output 输出m的阶乘的位数. ...

  6. Java实现 蓝桥杯VIP 算法训练 递归求二进制表示位数

    问题描述 给定一个十进制整数,返回其对应的二进制数的位数.例如,输入十进制数9,其对应的二进制数是1001,因此位数是4. 样例输入 一个满足题目要求的输入范例. 9 样例输出 与上面的样例输入对应的 ...

  7. HDU 1018 Big Number (log函数求数的位数)

    Problem Description In many applications very large integers numbers are required. Some of these app ...

  8. [BZOJ3000]Big Number(斯特林公式)

    求n!在k进制下的位数,n<=1e18 斯特林公式:$n!\approx \sqrt{2\pi n}(\frac{n}{e})^n$ 在n很大的时候有较好的精度保证. $\log_{k}n!+1 ...

  9. HDU-Big Number (斯特林公式)

    In many applications very large integers numbers are required. Some of these applications are using ...

随机推荐

  1. glib wpa_supplicant Unix上库编译错误解决与总结

    编译Linux下的库是一件痛苦的事情,这里主要阐述glib和wpa_supplicant库的编译,因各自的依赖关系,另外一些库要事先编译.glib依赖libffi和zlib,而wpa_supplica ...

  2. Matlab自带的曲线拟合程序

    这个函数的功能是能自动搜索参数的取值,从而使得方程的误差最小. 效果如下 代码如下 %% Optimal Fit of a Non-linear Function % This is a demons ...

  3. edittext SearchView 失去焦点问题

    edittext 默认自己主动获取焦点的 并且会出现小键盘非常烦人 <LinearLayout             android:id="@+id/focus"     ...

  4. dubbo方法调用的timeout设置

    方法调用的默认超时时间为1s,但是具体的超时时间受限于服务端方法性能.服务端个数.客户端的并发数等因素,所以超时时间需要根据不同的场景进行调试. 基本步骤为: 测试服务端的TPS,单位为 任务数或线程 ...

  5. 在Dell XPS 13安装WIN10和ubuntu双系统

    新入了Dell的XPS 13超级本,之所以买这个本子,就是看中它轻便且续航持久.这款本子也是为数不多的能够和苹果的13'' mac book air一较高下的本子.在重量上,占地面积和综合性价比上,还 ...

  6. 火车票抢票API 根据乘客的车次与座席要求快速订票出票

    火车票抢票API 根据乘客的车次与座席要求快速订票出票:https://www.juhe.cn/docs/api/id/257 1.站站查询 接口地址:http://v.juhe.cn/grabTic ...

  7. Openerp图片路径处理

    Openerp目前存储图片如人力资源头像图片等都是以二进制的方式存储在数据库中,若要修改数据库里只存储路径可以用这种方法 Image 装饰器: Image装饰器包含3中图片显示 Image 大图片 i ...

  8. Java 遍历一个对象的属性 将非空属性赋值给另一个对象

    //将origin属性注入到destination中 public <T> void mergeObject(T origin, T destination) { if (origin = ...

  9. VIM-不常用或不知道的技巧

    cc 清除一行 并在本行编辑, 同理 cw :32,65d 多行删除 g/pattern/d 删除包含特定字符的行 v/pattern/d 删除不包含指定字符的行 等同于 g!/pattern/d y ...

  10. spring配置,spring中的bean 的id不能相同

    lib下加入包 spring.jar commons-logging.jar src下添加 applicationContext.xml <?xml version="1.0" ...