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 ≤ 10 7 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的位数为log10(n)+1    将大数利用log变为小数直接来计算位数
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int n;
cin>>n;
while(n--)
{
int a;
double b=;
cin>>a;
for(int i=;i<=a;i++){
b+=log10((double)i);
}
cout<<(int)b+<<endl;
}
//system("pause");
return ;
}
 
 

C - Big Number的更多相关文章

  1. JavaScript Math和Number对象

    目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ...

  2. Harmonic Number(调和级数+欧拉常数)

    题意:求f(n)=1/1+1/2+1/3+1/4-1/n   (1 ≤ n ≤ 108).,精确到10-8    (原题在文末) 知识点:      调和级数(即f(n))至今没有一个完全正确的公式, ...

  3. Java 特定规则排序-LeetCode 179 Largest Number

    Given a list of non negative integers, arrange them such that they form the largest number. For exam ...

  4. Eclipse "Unable to install breakpoint due to missing line number attributes..."

    Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统 ...

  5. 移除HTML5 input在type="number"时的上下小箭头

    /*移除HTML5 input在type="number"时的上下小箭头*/ input::-webkit-outer-spin-button, input::-webkit-in ...

  6. iOS---The maximum number of apps for free development profiles has been reached.

    真机调试免费App ID出现的问题The maximum number of apps for free development profiles has been reached.免费应用程序调试最 ...

  7. 有理数的稠密性(The rational points are dense on the number axis.)

    每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.

  8. [LeetCode] Minimum Number of Arrows to Burst Balloons 最少数量的箭引爆气球

    There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided ...

  9. [LeetCode] Number of Boomerangs 回旋镖的数量

    Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of po ...

  10. [LeetCode] Number of Segments in a String 字符串中的分段数量

    Count the number of segments in a string, where a segment is defined to be a contiguous sequence of ...

随机推荐

  1. VS 2003 无法打开Web项目 文件路径与URL不符 这两者需要映射到相同的服务器位置

    解决方法: 将C:\Documents   and   Settings\Administrator\VSWebCache下面的文件全部删除

  2. 使用Spring JDBCTemplate简化JDBC的操作

    使用Spring JDBCTemplate简化JDBC的操作 接触过JAVA WEB开发的朋友肯定都知道Hibernate框架,虽然不否定它的强大之处,但个人对它一直无感,总感觉不够灵活,太过臃肿了. ...

  3. (转) int argc, char* argv[] 的用法

    int main(int argc, char* argv[]) 這兩個參數的作用是什麼呢?argc 是指命令行輸入參數的個數,argv存儲了所有的命令行參數.假如你的程式是hello.exe,如果在 ...

  4. CDZSC_2015寒假新人(2)——数学 C

    C - C Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  5. After a rest, go on

    busy during the whole May holiday. running between S and H, waste much time leaving things behind. t ...

  6. 用ant重新编译jdk加入调试信息

    (文章后面提供了ant和build.xml打包之后的build.zip下载,解压build.zip,然后将apache-ant-1.9.2-bin.zip解压即完成了ant安装,也可到http://a ...

  7. Orchard开源ASP.NET MVC CMS简介

    项目简介: Orchard CMS 是一个免费的开放源代码内容管理系统,让用户可在 Microsoft ASP.NET MVC 平台上快速创建网站.它基于灵活的扩展性框架构建,使开发人员和定制人员可通 ...

  8. css使用技巧

    1) 网站上经常会出现用户输入一大段字符和字母以至于文字无法正常折行,把版式破坏,这样我们就要参考以下样式:word-wrap:break-word; overflow:hidden; 当然必须得有宽 ...

  9. 函数stripslashes去除转义 shopnc 搜索框过滤特殊字符 输入单斜杆会自动转义

    如何php是如何处理和过滤特殊字符的呢? 搜索%_显示所有商品:搜索\会在搜索框内叠加\\ 查了一下 magic_quotes_sybase 项开启,反斜线将被去除,但是两个反斜线将会被替换成一个. ...

  10. shell脚本练习(短路练习)

    #!/bin/bash #By Spinestars#2013-11-11#This is a lvsnap of auto-create Help(){ echo "Usage: ---d ...