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 ...
随机推荐
- PHP学习系列(1)——字符串处理函数(5)
31.ord() 函数返回字符串第一个字符的 ASCII 值. 语法:ord(string) 例子 <?php echo ord("h"); echo ord("h ...
- cad 画 tp图
本文记录了cad 绘制 结构图 和触摸屏激光图. 1作为一个新手,我先要做的是适应操作界面. 页面:ctrl+鼠标滚轮 (类比,ps,ad等软件都是这样的.) 选取,划线,图层.等... 2画图... ...
- cf B. Vasya and Public Transport
http://codeforces.com/contest/355/problem/B #include <cstdio> #include <cstring> #includ ...
- Linux 杀死挂起的进程
在用管理员执行一个命令后,用Ctrl+Z把命令转移到了后天.导致无法退出root的. 输入命令:exit终端显示:There are stopped jobs. 解决方法:方法一.输入命令:jobs终 ...
- 【Xamarin开发IOS-IOS生命周期】
iOS的应用程序的生命周期,还有程序是运行在前台还是后台,应用程序各个状态的变换,这些对于开发者来说都是很重要的. iOS系统的资源是有限的,应用程序在前台和在后台的状态是不一样的.在后台时,程序会受 ...
- NOI2012 骑行川藏
http://www.lydsy.com/JudgeOnline/problem.php?id=2876 表示完全不会...... 还是跪拜大神吧 http://www.cnblogs.com/Ger ...
- hdu4623:crime 数学优化dp
鞍山热身赛的题,也是去年多校原题 题目大意: 求n个数的排列中满足相邻两个数互质的排列的数量并取模 当时的思路就是状压dp.. dp[i][state] state用二进制记录某个数是否被取走,i ...
- poj3358:欧拉定理
又是一道用欧拉定理解的题..嗯,关键还是要建好方程,注意一些化简技巧 题目大意: 给定一个由 p / q 生成的循环小数,求此循环小数在二进制表示下的最小循环节以及不是循环节的前缀 思路: 小数化为二 ...
- windows msiexec quiet静默安装及卸载msi软件包
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoUAAAA4CAIAAAAEgBUBAAAIj0lEQVR4nO2dQXLcOAxFdbXJ0aZys6
- poj 2046 Gap(bfs+hash)
Description Let's play a card game called Gap. You have cards labeled with two-digit numbers. The fi ...