hdu 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 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
阶乘的位数:
log10(1)+1=1;
log10(10)+1=2;
log10(100)+1=3;
等等;
由此规律来求阶乘的位数
代码:
#include<iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;
int k;
double x,y;
int main()
{
int n,m,i,j; while(cin>>n)
{
while(n--)
{ x=0;
cin>>m;
for(i=1;i<=m;i++)
{
x=x+log10(i); }
k=x+1;
cout<<k<<endl;
}
}
return 0; }
hdu Big Number 求一个数的位数的更多相关文章
- NEFU 117 - 素数个数的位数 - [简单数学题]
题目链接:http://acm.nefu.edu.cn/JudgeOnline/problemShow.php?problem_id=117 Time Limit:1000ms Memory Limi ...
- HDU 1018 大数(求N!的位数/相加)
Big Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- HDU 3709 Balanced Number 求区间内的满足是否平衡的数量 (数位dp)
平衡数的定义是指,以某位作为支点,此位的左面(数字 * 距离)之和 与右边相等,距离是指某位到支点的距离; 题意:求区间内满足平衡数的数量 : 分析:很好这又是常见的数位dp , 不过不同的是我们这次 ...
- HDU 1018-Big Number(数学)
Big Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- hdu 5869 区间不同GCD个数(树状数组)
Different GCD Subarray Query Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K ( ...
- 75 int类型数组中除了一个数出现一次或两次以外,其他数都出现三次,求这个数。[2行核心代码]
[本文链接] http://www.cnblogs.com/hellogiser/p/single-number-of-array-with-other-three-times.html [题目] i ...
- LightOj 1024 - Eid (求n个数的最小公约数+高精度)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1024 题意:给你n(2<=n<=1000)个数, 然后求n个数的最小公倍数 ...
- HDU 1711 Number Sequence(数列)
HDU 1711 Number Sequence(数列) Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...
- HDU 1005 Number Sequence(数列)
HDU 1005 Number Sequence(数列) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Jav ...
随机推荐
- C++,关于类和结构体中,成员访问属性(public,private)
今天发现一个的问题: #include <vector> #include <iostream> #include <algorithm> #include < ...
- POj3421 X-factor Chains(质因数分解+排列组合)
POj3421X-factor Chains 一开始没读懂题意,不太明白 Xi | Xi+1 where a | b means a perfectly divides into b的意思,后来才发现 ...
- MySQL STRAIGHT_JOIN
问题 最近在调试一条查询耗时5s多的sql语句,这条sql语句用到了多表关联(inner join),按时间字段排序(order by),时间字段上已经创建了索引(索引名IDX_published_a ...
- flask开发restful api系列(3)--利用alembic进行数据库更改
上面两章,主要讲基本的配置,今天我们来做一个比较有趣的东西,为每个客户加一个头像图片.如果我们图片保存在自己的服务器,对于服务器要求有点高,每次下载的时候,都会阻塞网络接口,要是1000个人同时访问这 ...
- 解决“您必须先更新GOOGLE play才能运行此应用”的问题
可以手机FQ然后更新,但是这样更新速度很慢,而且google商店上面的版本还是老版本. 正确的方法:去https://www.pushbullet.com/channel-popup?tag=am21 ...
- sqlachemy 使用实例
sqlachemy 是python中关于sql的ORM,他的存在可以消除底层sql引擎的差异,同事也避免了复杂繁琐的sql语句,因此我们在比较大的应用时常使用它,下面是我写的一个例子 #!/usr/b ...
- 封装JDBC事务操作,执行存储过程测试
Oracle数据库端测试环境见:http://www.cnblogs.com/yshyee/p/4392328.html package com.mw.utils; import java.sql.C ...
- 关于Android的一些理解
Activity中写回调函数 View的回调函数-------->事件回调 Activity层--------------->生命周期回调函数.事件回调函数 Window层 Layout是 ...
- JavaScript对象基础知识
1.对象所包含的元素一组包含数据的属性.如人的名字.书的价格和手机型号等.允许对属性中所包含的数据进行操作的方法. 2.引用对象的途径一个对象真正地被使用,可以采用以下几种方式.引用Javascrip ...
- 树莓派 (Raspberry Pi) 是什么?普通人怎么玩?(私有云NAS也会有;上传到百度盘的功能nas也有)
作者:王震宇链接:https://www.zhihu.com/question/20859055/answer/54734499来源:知乎著作权归作者所有,转载请联系作者获得授权. 我两年前买的(约2 ...