Big Number

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 32410    Accepted Submission(s): 15175
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
 
Recommend
JGShining   |   We have carefully selected several similar problems for you:  1013 1017 1071 1019 1021 

刚看题的时候没看数据范围,傻乎乎的用大数阶乘,后来才发现有规律啊!!
附上大数的,但是不会过
//#include<stdio.h>
//#include<string.h>
//int main()
//{
// int t;
// scanf("%d",&t);
// int n,num[200];
// while(t--)
// {
// memset(num,0,sizeof(num));
// num[0]=1;
// scanf("%d",&n);
// int j;
// int c=0;
// for(int i=1;i<=n;i++)
// {
// for(j=0;j<=199;j++)
// {
// num[j]=num[j]*i+c;
// if(num[j]>=10)
// {
// c=num[j]/10;
// num[j]-=c*10;
// }
// else c=0;
// }
//
// }
// for(j=199;j>=0;j--)
// if(num[j]!=0)
// break;
// printf("%d\n",j+1);
// }
// return 0;
//}
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
double ans=0;
for(int i=1;i<=n;i++)
ans+=log10(i);
printf("%d\n",(int)ans+1);
}
return 0;
}

hdoj--1018--Big Number(简单数学)的更多相关文章

  1. HDOJ 1018 Big Number(大数位数公式)

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

  2. 计蒜客 31452 - Supreme Number - [简单数学][2018ICPC沈阳网络预赛K题]

    题目链接:https://nanti.jisuanke.com/t/31452 A prime number (or a prime) is a natural number greater than ...

  3. SDUT 3258 Square Number 简单数学

    和上一题一样,把平方因子除去,然后对应的数就变成固定的 #include <cstdio> #include <iostream> #include <algorithm ...

  4. SDUT 3257 Cube Number 简单数学

    把所有数的立方因子除去,那么一个数可以和它组成立方的数是确定的,统计就行 #include <cstdio> #include <iostream> #include < ...

  5. HDU 5073 Galaxy (2014 Anshan D简单数学)

    HDU 5073 Galaxy (2014 Anshan D简单数学) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5073 Description G ...

  6. HDOJ 1501 Zipper 【简单DP】

    HDOJ 1501 Zipper [简单DP] Problem Description Given three strings, you are to determine whether the th ...

  7. 水题 HDOJ 4727 The Number Off of FFF

    题目传送门 /* 水题:判断前后的差值是否为1,b[i]记录差值,若没有找到,则是第一个出错 */ #include <cstdio> #include <iostream> ...

  8. 洛谷试炼场-简单数学问题-P1403 [AHOI2005]-因数

    洛谷试炼场-简单数学问题 P1403 [AHOI2005]约数研究 Description 科学家们在Samuel星球上的探险得到了丰富的能源储备,这使得空间站中大型计算机"Samuel I ...

  9. 洛谷试炼场-简单数学问题-P1045 麦森数-高精度快速幂

    洛谷试炼场-简单数学问题 B--P1045 麦森数 Description 形如2^P−1的素数称为麦森数,这时P一定也是个素数.但反过来不一定,即如果PP是个素数,2^P-1 不一定也是素数.到19 ...

随机推荐

  1. python求两个列表的并集.交集.差集

    求两个列表的差集 >>> a = [1,2,3] >>> b=[1,2] >>> ################################ ...

  2. ES6变量的解构赋值

    变量的解构赋值 1.数组的解构赋值 2.对象的解构赋值 3.字符串的解构赋值 4.数值和布尔值的解构赋值 5.函数参数的解构赋值 6.圆括号问题 7.用途 1.数组的解构赋值 ES6 允许写成下面这样 ...

  3. Educational Codeforces Round 33

    # Who = Penalty * A B C D E F 479 arkethos 4 247   + 00:08 + 00:19 +1 00:59 +2 01:41     479  ne-leo ...

  4. deeplearning4j – 分布式DL开源项目

    原文链接:http://www.52ml.net/16157.html Deeplearning4j is the first commercial-grade deep learning libra ...

  5. 项目随笔@Service("testService")-------第二篇

    在springmvc中使用注解已经司空见惯了,今天见到了@Service("xxx")这种形式,让我大吃一惊.原来在service后面可以加参数,作为该service的名字,在sp ...

  6. 项目随笔之springmvc中freemark如何获取项目路径

    转载:http://blog.csdn.net/whatlookingfor/article/details/51538995 在SpringMVC框架中使用Freemarker试图时,要获取根路径的 ...

  7. js 获取 下拉框的值

    //错误 console.log($("#DictID").select.val()); //错误 console.log($("#DictID").selec ...

  8. TF从文件中读取数据

    从文件中读取数据 在TensorFlow中进行模型训练时,在官网给出的三种读取方式,中最好的文件读取方式就是将利用队列进行文件读取,而且步骤有两步: 把样本数据写入TFRecords二进制文件 从队列 ...

  9. vue 项目初始化、mock数据以及安装less

    vue 创建一个项目 1.首先建立一个空文件夹,然后将这个文件夹要放到码云或者其他代码管理平台. 例如码云: 在码云上建立一个项目,然后在控制台进入这文件夹执行 git clone 地址是码云上创建的 ...

  10. 推荐一款能支持国密SM2浏览器——密信浏览器

    密信浏览器( MeSince Browser )是基于Chromium开源项目开发的国密安全浏览器,支持国密算法和国密SSL证书,同时也支持国际算法及全球信任SSL证书:密信浏览器使用界面清新,干净. ...