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
  1. 2
  2. 10
  3. 20
 
Sample Output
  1. 7
  2. 19
 
Source
 
Recommend
JGShining   |   We have carefully selected several similar problems for you:  1013 1017 1071 1019 1021 

刚看题的时候没看数据范围,傻乎乎的用大数阶乘,后来才发现有规律啊!!
附上大数的,但是不会过
  1. //#include<stdio.h>
  2. //#include<string.h>
  3. //int main()
  4. //{
  5. // int t;
  6. // scanf("%d",&t);
  7. // int n,num[200];
  8. // while(t--)
  9. // {
  10. // memset(num,0,sizeof(num));
  11. // num[0]=1;
  12. // scanf("%d",&n);
  13. // int j;
  14. // int c=0;
  15. // for(int i=1;i<=n;i++)
  16. // {
  17. // for(j=0;j<=199;j++)
  18. // {
  19. // num[j]=num[j]*i+c;
  20. // if(num[j]>=10)
  21. // {
  22. // c=num[j]/10;
  23. // num[j]-=c*10;
  24. // }
  25. // else c=0;
  26. // }
  27. //
  28. // }
  29. // for(j=199;j>=0;j--)
  30. // if(num[j]!=0)
  31. // break;
  32. // printf("%d\n",j+1);
  33. // }
  34. // return 0;
  35. //}
  36. #include<stdio.h>
  37. #include<string.h>
  38. #include<math.h>
  39. int main()
  40. {
  41. int t;
  42. scanf("%d",&t);
  43. while(t--)
  44. {
  45. int n;
  46. scanf("%d",&n);
  47. double ans=0;
  48. for(int i=1;i<=n;i++)
  49. ans+=log10(i);
  50. printf("%d\n",(int)ans+1);
  51. }
  52. return 0;
  53. }

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. BZOJ 2324 (有上下界的)费用流

    思路: 先跑一遍Floyd  更新的时候map[i][j]=map[i][k]+map[k][j]  k需要小于i或j 正常建边: 把所有点 拆点-> i,i+n add(x,y,C,E)表示x ...

  2. WebDav协议基于HTTP 1

    首先第一篇提供配置WebDav的方式 网上找了两篇比较好的配置方式分别适用于Win7 Win2003,而且都经过测试配置可以正常使用 原文中保留了引用地址,这个纯属为了要尊重别人的劳动成果 在第二篇中 ...

  3. WPF黑色背景下常用控件样式

    平时工作用 自己整理的 代码等找到合适的上传空间在进行同步

  4. Svn install and use

    1.安装服务 使用yum安装subversion,简单.不繁琐. 1 yum install -y subversion 2.创建版本库 1 2       mkidr /svn/obj        ...

  5. 前端面试基础-html篇之CSS3新特性

    CSS3的新特性(个人总结)如下 过度(transiton) 动画(animation) 形状转换 transform:适用于2D或3D转换的元素 transform-origin:转换元素的位置(围 ...

  6. CSS3伪元素、伪类选择器

    伪元素选择器: ::first-letter:为某个元素中的文字的首字母或第一个字使用样式. ::first-line:为某个元素的第一行文字使用样式. ::before:在某个元素之前插入一些内容. ...

  7. BluetoothA2dp蓝牙音箱的连接

    1:权限 <uses-feature android:name="android.hardware.bluetooth_le" android:required=" ...

  8. django 安装运行

    pip install django pip list 查看版本 python -m django --version 新建django django-admin startproject mysit ...

  9. mvc cshtml 字符串操作

    @using System.Text; @{ ; string str=""; StringBuilder sb = new StringBuilder(); } @foreach ...

  10. .apply .call方法的区别及使用 .apply第二个参数为数组,.call第二个参数为参数列表, 相同点:第一个参数都为Function函数内部的this对象.

    Function.apply(obj,args)方法能接收两个参数 obj:这个对象将代替Function类里this对象 args:这个是数组,它将作为参数传给Function(args--> ...