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. mysql和eclipse连接jdbc驱动配置

    环境Windows10 eclipse 64位 MySQL 一:资料准备 (MySQL,eclipse下载安装不在赘述) 配置好MySQL环境后 下载jdbc地址http://dev.mysql.co ...

  2. 当接口上配了 FeignClient 和 RequestMapping 两个注解,结果错误提示 重复mapping处理方法

    再接手老文档的时候,发现有这么一个问题 错误显示为: 原文档写法: 解决方法: 这是一个编译时写法的问题,将上方的RequestMapping去掉,然后把路径放在下面的PostMapping 便可以正 ...

  3. MFC知识点总结

    一:消息1.什么是消息?消息是驱动windows系统运行的基础.从计算机的角度来看,消息就是一个整数.    (1)一个无符号整数,是消息值:    (2)消息附带的WPARAM和LPARAM类型的参 ...

  4. Online ML那点事>-

    一:译自wiki:    KeyWord:标签反馈; Survey: online machine learning is a model of induction that learns one i ...

  5. vue组件之间互相传值:父传子,子传父

    今看到一篇很不错的vue组件传值文章,便于理解,遂做笔记- 一般页面的视图App.vue应为这样 一.父组件向子组件传值 1.创建子组件,在src/components/文件夹下新建一个Child.v ...

  6. 原生sql的各种问题

    1.nutz有方法自动根据数据库建models吗?2.select * from a a没有建相应的models怎么取结果?3.可以直接操作result,而不是在callback里面设置吗? wend ...

  7. sql语句参数化问题

    select  @PageSize * from tets SELECT 在WHERE 之前都不能参数化. TOP 只能做字符串运行.

  8. 软件神器系列——photozoom图片像无损清晰放大软件砸金蛋活动开始啦!

    不管是刚进入社会的小白,还是混迹多年的油条,是不是发现了最近的工作越来越难做了? 推广文章.产品手册.营销方案.培训计划.工作报告乃至于PPT,都不是以前用文字数据可以交工的了,现在都讲究“图文并茂” ...

  9. Debian 6 , 十个串口为什么只识别到了 6个 剩下4 个被禁止了

    0.946441] Serial: 8250/16550 driver, 6 ports, IRQ sharing enabled [    0.946533] serial8250: ttyS0 a ...

  10. vc++如何创建程序-函数的重载

    重载构成的条件:函数的参数类型,参数个数不同,才能构成函数的重载 函数重载分为两种情况: 1 .(1)void output(); (2)int output(); 2 .(1)void output ...