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. Parity game---poj1733

    Description Now and then you play the following game with your friend. Your friend writes down a seq ...

  2. vue 中 命名视图的用法

    今天主要记录  vue中命名视图的用法 先奉上官网网址:https://router.vuejs.org/zh/guide/essentials/named-views.html 一般情况下,一个页面 ...

  3. 洛谷P3166 数三角形 [CQOI2014] 数论

    正解:数论 解题报告: 传送门! 很久以前做的题了呢,,,回想方法还想了半天QAQ 然后写这题题解主要是因为看到了好像有很新颖的法子,就想着,学习一下趴,那学都学了不写博客多可惜 首先港下最常规的方法 ...

  4. [py]requests+json模块处理api数据,flask前台展示

    需要处理接口json数据,过滤字段,处理字段等. 一大波json数据来了 参考: https://stedolan.github.io/jq/tutorial/ https://api.github. ...

  5. poj1753Flip Game(dfs)

    Flip Game  思想很不成熟, #include <stdio.h>#include <string.h>#include <stdlib.h>int map ...

  6. 弱分类器的进化--Bagging、Boosting、Stacking

    一般来说集成学习可以分为三大类: 用于减少方差的bagging 用于减少偏差的boosting 用于提升预测结果的stacking 一.Bagging(1996) 1.随机森林(1996) RF = ...

  7. 集合框架—HashMap

    HashMap提供了三个构造函数:       HashMap():构造一个具有默认初始容量 (16) 和默认加载因子 (0.75) 的空 HashMap.       HashMap(int ini ...

  8. mov指令

    一.规定 1.立即数不能作为目的操作数,如mov 110H,AX 2.立即数不能直接传给段寄存器,如mov DS,110H 2.两个操作数不能同时为段寄存器,如mov ES,DS 3.两个操作数不能同 ...

  9. IN的另类写法

    EXPLAIN SELECT * FROM `tcb_capital_log` WHERE id IN(66,79,47) EXPLAIN SELECT * FROM ( SELECT 66 AS i ...

  10. Navicat 连接 Mysql8.0 出现2059问题的解决方法

    ``` 登陆Mysql后执行命令 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; ...