Big Number

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

Total Submission(s): 40782    Accepted Submission(s): 19958

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

思路:

原来还有这种操作:求n的位数为(int)log10(n)+1,阶乘为相加后加1

code

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<cctype>
#include<queue>
#include<math.h>
#include<iostream>
#include<algorithm>
#define INF 0x3f3f3f3f
#define N 85
using namespace std;
int main(){
int t,n,i;
double sum;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
sum=0;
for(i=1;i<=n;i++){
sum+=log10(i);
}
printf("%d\n",(int)sum+1);
}
return 0;
}

Big Number-Asia 2002, Dhaka (Bengal) (计算位数)题解的更多相关文章

  1. HDU 1018Big Number(大数的阶乘的位数,利用公式)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1018 Big Number Time Limit: 2000/1000 MS (Java/Others) ...

  2. PHP简单的计算位数的函数

    一个简单的PHP计算位数的函数: 1 <?php 2 //一个简单的计算字符串有长度的函数 3 #开始定义函数 4 function count_digit($number){ 5 $count ...

  3. Duanxx的C++得知:计算位数

    一旦计算出一个数值数字,基本上它是不断分裂使用10.重新计,看看有多少个数字. 今天发现能够考虑先将数字转换为字符串,然后通过string.length获得数值的位数,这样做方便的多. string ...

  4. 2018 ACM-ICPC Asia Beijing Regional Contest (部分题解)

    摘要 本文主要给出了2018 ACM-ICPC Asia Beijing Regional Contest的部分题解,意即熟悉区域赛题型,保持比赛感觉. Jin Yong’s Wukong Ranki ...

  5. 2014-2015 ACM-ICPC, Asia Xian Regional Contest(部分题解)

    摘要 本文主要给出了2014-2015 ACM-ICPC, Asia Xian Regional Contest的部分题解,说明了每题的题意.解题思路和代码实现,意即熟悉区域赛比赛题型. Built ...

  6. Math Number 数值类 包装类 数学计算 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  7. HDU 1018 Big Number (log函数求数的位数)

    Problem Description In many applications very large integers numbers are required. Some of these app ...

  8. input的类型为number,限制输入的数字位数

    <input type="text"  maxlength="5" />   效果ok,当 <input type="number& ...

  9. The 2018 ACM-ICPC Asia Qingdao Regional Contest(部分题解)

    摘要: 本文是The 2018 ACM-ICPC Asia Qingdao Regional Contest(青岛现场赛)的部分解题报告,给出了出题率较高的几道题的题解,希望熟悉区域赛的题型,进而对其 ...

随机推荐

  1. qt——for循环里创建widget

    在for循环里创建 widget,比如test类 不能使用 test t; 而要使用 test t = new test(): for (i=0;i<=3;i++) { QPushButton* ...

  2. mysql 用户与权限

    1.用户 1)创建用户   "create user '用户'@'host' identified by '密码';" 在5.7以后的版本中要求密码包含至少一个大写字母,一个小写字 ...

  3. MSMQ研究

    开发过程记录如下: 1.   本机配置MSMQ ------控制面板-------启动或者关闭Windows功能----默认安装MSMQ即可 注意:本地安装后再VS中才能引用System.Messag ...

  4. create-react-app创建react项目失败!

    create-react-app my-app 用管理员运行cmd,问题依然. 打开日志,看到错误详细信息如下 32189 verbose unlock done using C:\Users\fen ...

  5. win10 问题:你没有权限在此位置中保存文件。请与管理员联系以获得相应权限。

    https://jingyan.baidu.com/album/b24f6c8207f09886bee5da4a.html?picindex=2 归根结底就是通过点击文件夹的属性,在安全选项处,修改操 ...

  6. Git简单入门教程

    1.下载Git,360的软件管家里搜 2.安装Git,下载好之后安装到指定路径下 安装方法有多个复选框的把第一个也选上,其他默认直接next,最后一步什么都不选 3.配置用户信息:(右键-->g ...

  7. spark shuffle原理

    1.spark中窄依赖的时候不需要shuffle,只有宽依赖的时候需要shuffle,mapreduce中map到reduce必须经过shuffle 2.spark中的shuffle fetch的时候 ...

  8. python中 staticmethod与classmethod

    原文地址https://blog.csdn.net/youngbit007/article/details/68957848 原文地址https://blog.csdn.net/weixin_3565 ...

  9. zw版【转发·台湾nvp系列Delphi例程】HALCON LocalMin1

    zw版[转发·台湾nvp系列Delphi例程]HALCON LocalMin1 zw版[转发·台湾nvp系列Delphi例程]HALCON LocalMin1 procedure TForm1.But ...

  10. Root :: AOAPC I: Beginning Algorithm Contests (Rujia Liu) Volume 5. Dynamic Programming

    10192 最长公共子序列 http://uva.onlinejudge.org/index.php?option=com_onlinejudge& Itemid=8&page=sho ...