Big Number

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

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
题目大意:问n的阶乘有多少位。
思路:数学!我们发现阶乘的位数可以这么计算:

t+=log10(i*1.00);
sum=int(t)+1;

这样就很好的求出位数了。
代码:
 1 #include<iostream>
2 #include<stdio.h>
3 #include<string.h>
4 #include<cmath>
5 #include<math.h>
6 using namespace std;
7 int main(){
8 int T;
9 cin>>T;
10 while(T--){
11 int n;
12 scanf("%d",&n);
13 int sum=0;
14 double t=0.0;
15 for(int i=1;i<=n;i++){
16 t+=log10(i*1.00);
17 }
18 sum=int(t)+1;
19 cout<<sum<<endl;
20 }
21 return 0;
22 }


HDU 1108的更多相关文章

  1. HDU 1108 最小公倍数

    #include <cstdio> int gcd(int a,int b) { ) return a; else return gcd(b,a%b); } int main() { in ...

  2. HDU 1222 - Wolf and Rabbit & HDU 1108 - [最大公约数&最小公倍数]

    水题,只是想借此记一下gcd函数的模板 #include<cstdio> int gcd(int m,int n){return n?gcd(n,m%n):m;} int main() { ...

  3. HDU 1108.最小公倍数-辗转相除法

    最小公倍数 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  4. HDU题解索引

    HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsu ...

  5. hdu 2503 1713 1108 最小公倍数&最大公约数

    gcd模板: __int64 gcd(__int64 a,__int64 b) { retur b==0?a:gcd(b,a%b); } 1108: #include<iostream> ...

  6. ZOJ 1108 FatMouse's Speed (HDU 1160) DP

    传送门: ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=108 HDU :http://acm.hdu.edu.cn/s ...

  7. ZOJ 1108 & HDU 1160 - FatMouse's Speed

    题目大意:给你n只老鼠的体重w和速度s,让你找出最长的子序列使得w[i] < w[j] 且 s[i] > s[j] (i < j).求最长序列的长度并输出该序列. LIS(Longe ...

  8. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  9. HDU 4422 The Little Girl who Picks Mushrooms(简单题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4422 题目大意:小姑娘背着5个包去山上采蘑菇,每座山上只能用一个背包采集.三个小精灵会要她3个背包,其 ...

  10. [转] HDU 题目分类

    转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...

随机推荐

  1. 使用flask开发web应用

    Flask环境搭建 要开发flash应用,我们需要做一些准备工作 我写了个初始化的脚本 Pip_init.sh来安装初始工作 可以到我的git上去下载该脚本进行初始化安装 要启动flask应用,我们需 ...

  2. 织梦tag怎么显示每个tag相应的文章数量

    有些时候我们想实现类似于wordpress那样的tag,就是在显示tag的链接和tag名的同时,还能显示每个tag关联的文章的数量.如下图所示: 这就需要修改/include/taglib/tag.l ...

  3. redis基本数据类型 List

    127.0.0.1:6379> LPUSH test a (integer) 1 127.0.0.1:6379> LPUSH test b (integer) 2 127.0.0.1:63 ...

  4. 【Python爬虫实战】爬虫封你ip就不会了?ip代理池安排上

    前言 在进行网络爬取时,使用代理是经常遇到的问题.由于某些网站的限制,我们可能会被封禁或者频繁访问时会遇到访问速度变慢等问题.因此,我们需要使用代理池来避免这些问题.本文将为大家介绍如何使用IP代理池 ...

  5. EtherCAT转Modbus网关做为 MODBUS 从站配置

    EtherCAT转Modbus网关做为 MODBUS 从站配置案例 兴达易控EtherCAT转Modbus网关可以用作MODBUS从站的配置.这种网关允许将Modbus协议与EtherCAT协议进行转 ...

  6. MySQL innoDB 间隙锁产生的死锁问题

    背景 线上经常偶发死锁问题,当时处理一张表,也没有联表处理,但是有两个mq入口,并且消息体存在一样的情况,频率还不是很低,这么一个背景,我非常容易怀疑到,两个消息同时近到这一个事务里面导致的,但是是偶 ...

  7. 【翻译】listener.ora

    今天仔细过一遍oracle的监听配置文件描述. cat $ORACLE_HOME/network/admin/samples/listener.ora # copyright (c) 1997 by ...

  8. Spring Cloud OpenFeign系列:简介和使用

    目录 一.简介 二.使用 1.创建父工程 2.创建order-service模块 3.创建order-client模块 三.效果 四.配置说明 1.超时配置 全局超时配置 局部超时配置 2.Gzip压 ...

  9. "科来杯"第十届山东省大学生网络安全技能大赛决赛复现WP

    从朋友那里得来的附件,感觉题目有意思,简单复现一下 MISC 简单编码 1.题目信息 0122 061 1101011 0172 0122 0105 061 1011010 0127 0154 014 ...

  10. redis主从同步及redis哨兵机制

    1.主从和哨兵的作用: 角色 作用 主从 1.(提供)数据副本:多一份数据副本,保证redis高可用 2.  扩展(读)性能:如容量.QPS等 哨兵 1.监控: 监控redis主库及从库运行状态: 2 ...