How Many Digits?

Often times it is sufficient to know the rough size of a number, rather than its exact value. For example, a human can reason about which store to visit to buy milk if one store is roughly 11 kilometer away, and another store is roughly 100100 kilometers away. The exact distance to each store is irrelevant to the decision at hand; only the sizes of the numbers matter.

For this problem, determine the ‘size’ of the factorial of an integer. By size, we mean the number of digits required to represent the answer in base-1010.

Input

Input consists of up to 1000010000 integers, one per line. Each is in the range [0,1000000][0,1000000]. Input ends at end of file.

Output

For each integer nn, print the number of digits required to represent n!n! in base-1010.

Sample Input 1 Sample Output 1
0
1
3
10
20
1
1
1
7
19

题意

求n的阶乘的长度

思路

公式https://zh.wikipedia.org/wiki/%E6%96%AF%E7%89%B9%E9%9D%88%E5%85%AC%E5%BC%8F

#include<bits/stdc++.h>
using namespace std;
double ans[]={};
int main(){
int n;
for(int i=;i<=;i++){
ans[i]+=ans[i-]+log10(i);
}
while(cin>>n){
cout<<int(ans[n]+)<<endl;
}
}

Kattis - How Many Digits?的更多相关文章

  1. [LeetCode] Reconstruct Original Digits from English 从英文中重建数字

    Given a non-empty string containing an out-of-order English representation of digits 0-9, output the ...

  2. [LeetCode] Remove K Digits 去掉K位数字

    Given a non-negative integer num represented as a string, remove k digits from the number so that th ...

  3. [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  4. [LeetCode] Add Digits 加数字

    Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. ...

  5. LeetCode 258. Add Digits

    Problem: Given a non-negative integer num, repeatedly add all its digits until the result has only o ...

  6. ACM: FZU 2105 Digits Count - 位运算的线段树【黑科技福利】

     FZU 2105  Digits Count Time Limit:10000MS     Memory Limit:262144KB     64bit IO Format:%I64d & ...

  7. Revolving Digits[EXKMP]

    Revolving Digits Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  8. 【LeetCode】Add Digits

    Add Digits Given a non-negative integer num, repeatedly add all its digits until the result has only ...

  9. Add Digits, Maximum Depth of BinaryTree, Search for a Range, Single Number,Find the Difference

    最近做的题记录下. 258. Add Digits Given a non-negative integer num, repeatedly add all its digits until the ...

随机推荐

  1. gazebo 7.0 升级到7.15 参考他人博客

    gazebo 7.0 升级到7.14 网址:https://blog.csdn.net/riancy_riancy/article/details/84568322 编译后遇到报错 ,解决问题的网址: ...

  2. BZOJ 1266: [AHOI2006]上学路线route Floyd_最小割

    十分简单的一道题. 图这么小,跑一边 Floyd 就得到第一问最短路径的答案. 考虑第二问怎么求:我们可以先将最短路径组成的图从原图中抽离出来,构成新图 $G$. 我们发现,只要 $G$ 的起点与终点 ...

  3. 洛谷P1297 [国家集训队]单选错位_数学期望

    考虑第 iii 位, 那么当前共有 a[i]a[i]a[i] 种选项,那么当前选项正确的情况就是下一个被误填的答案与当前答案相同.换句话说,当前答案一共有 a[i]a[i]a[i] 种可能,而下一个答 ...

  4. Nginx全局变量

    一.全局变量 $args #请求中的参数值 $query_string #同 $args $arg_NAME #GET请求中NAME的值 $is_args #如果请求中有参数,值为"?&qu ...

  5. Python数据结构1-----基本数据结构和collections系列

    1.基本数据结构 整型.浮点型.字符串.元祖.列表.字典.集合 2.高级数据结构 (collections模块) (1)计数器(counter):对字典的补充,用于追踪值的出现次数. [具备字典所有的 ...

  6. 安装ubuntu14.04之后要做的一些事

    前言: 用ubuntu14.04也有一段时间了,感觉与之前版本相比还是在挺多方面有了改进.但刚装完还是有一些小问题需要自己动手解决.鉴于网上的内容太过零碎,有些方案也太过老旧,因此在这里为大家总结一些 ...

  7. 漫谈 Google 的 Native Client(NaCl) 技术(二)---- 技术篇(兼谈 LLVM)

    转自:http://hzx5.blog.163.com/blog/static/40744388201172531637729/ 漫谈 Google 的 Native Client(NaCl) 技术( ...

  8. Project Euler 27 Quadratic primes( 米勒测试 + 推导性质 )

    题意: 欧拉发现了这个著名的二次多项式: f(n) = n2 + n + 41 对于连续的整数n从0到39,这个二次多项式生成了40个素数.然而,当n = 40时402 + 40 + 41 = 40( ...

  9. MAVEN 构建包的引用

    1.什么叫构建包的引用? 当你存在两个maven项目分别是项目A,项目B时,且项目B要引用项目A的方法,那么你就用把项目A打成*.jar架包,放到本地的Maven仓库提供给项目B去引用. A.用命令到 ...

  10. HDU 3567 Eight II

    Eight II Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: 3 ...