HDU1018-Big Number

时间:2022-12-09 09:51:46

Big Number

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

Total Submission(s): 36450    Accepted Submission(s): 17456

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
 
思路:
一个数的位数等于他对10取对数+1
源代码:
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int main()
{
int t;
int num;
double sum;
scanf("%d",&t);
while(t--)
{
sum=0;
scanf("%d",&num);
for(int i=1;i<=num;i++)
{
sum+=log10((double)i);
}
printf("%d\n",(int)sum+1);
}
return 0;
}


HDU1018-Big Number的更多相关文章

  1. hdu1018 Big Number 斯特林公式 求N&excl;的位数。

    Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  2. JavaScript Math和Number对象

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

  3. Harmonic Number&lpar;调和级数&plus;欧拉常数&rpar;

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

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

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

  5. Eclipse &quot&semi;Unable to install breakpoint due to missing line number attributes&period;&period;&period;&quot&semi;

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

  6. 移除HTML5 input在type&equals;&quot&semi;number&quot&semi;时的上下小箭头

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

  7. iOS---The maximum number of apps for free development profiles has been reached&period;

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

  8. 有理数的稠密性&lpar;The rational points are dense on the number axis&period;&rpar;

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

  9. &lbrack;LeetCode&rsqb; Minimum Number of Arrows to Burst Balloons 最少数量的箭引爆气球

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

  10. &lbrack;LeetCode&rsqb; Number of Boomerangs 回旋镖的数量

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

随机推荐

  1. CentOS安装zip unzip命令

    yum install zip unzip

  2. Listview的onItemClickListener无法响应的解决方法(转)

    转:http://www.cnblogs.com/androidez/archive/2013/03/08/2950425.html 开发中很常见的一个问题,项目中的listview不仅仅是简单的文字 ...

  3. mysqladmin note

    hr,fresh meat!! --------------------------------------------------- 15 Practical Usages of Mysqladmi ...

  4. PHP 正则表达式常用函数使用小结

    在PHP中有两套正则表达式函数库.一套是由PCRE(Perl Compatible Regular Expression)库提供的.PCRE库使用和Perl相同的语法规则实现了正则表达式的模式匹配,其 ...

  5. &lpar;转)C&num; Base64

    本文原地址:http://blog.csdn.net/zhoufoxcn/article/details/1497092 作者:周公 using System;using System.Text; n ...

  6. 【转】Spring&plus;Hibernate&plus;EHcache配置&lpar;一&rpar;

    大量数据流动是web应用性能问题常见的原因,而缓存被广泛的用于优化数据库应用.cache被设计为通过保存从数据库里load的数据来减少应用和数据库之间的数据流动.数据库访问只有当检索的数据不在cach ...

  7. &lbrack;React&rsqb; React Router&colon; hashHistory vs browserHistory

    In this lesson we'll look at hashHistory which uses a hash hack to track our route changes vs browse ...

  8. Java核心技术 卷Ⅰ 基础知识(2)

    第四章 对象与类 基于类的访问权限 静态域 类的设计技巧

  9. TTL转MIPI DSI芯片方案TC358778XBG

    型号:TC358778XBG功能:TTL转MIPI DSI通信方式:IIC分辨率:1920*1080电源:3.3/1.8/1.2封装形式:BGA80深圳长期现货 ,提供技术支持,样品申请及规格书请联系 ...

  10. Java在ServletContextListener、过滤器、拦截器解决对象无法注入问题

    1.通用方法: // 数据库日志操作对象 private LogInfoServiceIFC logInfoServiceProxy; @Override public void contextIni ...