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. ajax用户名校验demo详解

    //用户名校验的方法 //这个方法使用XMLHTTPRequest对象进行AJAX的异步数据交互 var xmlhttp; function verify(){ //1.使用dom的方式获取文本框中的 ...

  2. Tomcat学习笔记 - 错误日志 - NetBeans配置tomcat出错情况总结 -- 部署错误: 启动 Tomcat 失败。-- '127.0.0.1' 不是内部或外部命令,也不是可运行的程序

    真的管用,不知道为啥管用.转载自:http://blog.sina.com.cn/s/blog_709548200102vgy4.html 问题描述: 新安装的NetBeans8.0.2,安装过程中还 ...

  3. [c language] getopt 其参数optind 及其main(int argc, char **argv) 参数解释

    getopt被用来解析命令行选项参数.#include <unistd.h> extern char *optarg; //选项的参数指针extern int optind, //下一次调 ...

  4. Python学习笔记(1)——数组差集

    面试的时候被问到这样一个问题:有A.B两个数组,找出B中有A中没有的所有元素(换言之即是求差集B-A).当时比较紧张,用了最原始的双重嵌套循环逐个比较,很显然这种时间复杂度高达O(n2)的算法相当lo ...

  5. information_schema.referential_constraints 学习

    information_schema.referential_constraints 表用于查看外键约束 1.information_schema.referential_constraints表的常 ...

  6. C++之------构造函数

    创建一个对象时,常常需要作某些初始化的工作,例如对数据成员赋初值. 类的数据成员是不能在声明类时初始化的. class Time { public : //声明为公用成员 hour; minute; ...

  7. 开心菜鸟系列学习笔记------javascript(4)

    一.全局上下文中的变量对象:        1)全局对象(Global object) 是在进入任何执行上下文之前就已经创建了的对象:这个对象只存在一份,它的属性在程序中任何地方都可以访问,全局对象的 ...

  8. jQuery插件之artDialog

    artDialog是一个非常强大的弹出框插件.默认有两个版本,一个是jQuery版,一个是javascript版.功能非常多,而且使用非常简单.不写了,直接贴上官网的预览运行地址,以后用得着的时候去那 ...

  9. windows bat脚本编写

    windows批处理 (cmd/bat) 编程详解 开始之前先简单说明下cmd文件和bat文件的区别:在本质上两者没有区别,都是简单的文本编码方式,都可以用记事本创建.编辑和查看.两者所用的命令行代码 ...

  10. c3p0链接池

    频繁的链接数据库是非常消耗性能的,所以就采用了将一定量的链接保存在一个池中,这个池我们叫做链接池. 详细请看:http://baike.baidu.com/link?url=dlTW-fTS3N_-j ...