Kattis - How Many Digits?
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 |
题意
求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?的更多相关文章
- [LeetCode] Reconstruct Original Digits from English 从英文中重建数字
Given a non-empty string containing an out-of-order English representation of digits 0-9, output the ...
- [LeetCode] Remove K Digits 去掉K位数字
Given a non-negative integer num represented as a string, remove k digits from the number so that th ...
- [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...
- [LeetCode] Add Digits 加数字
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. ...
- LeetCode 258. Add Digits
Problem: Given a non-negative integer num, repeatedly add all its digits until the result has only o ...
- ACM: FZU 2105 Digits Count - 位运算的线段树【黑科技福利】
FZU 2105 Digits Count Time Limit:10000MS Memory Limit:262144KB 64bit IO Format:%I64d & ...
- Revolving Digits[EXKMP]
Revolving Digits Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- 【LeetCode】Add Digits
Add Digits Given a non-negative integer num, repeatedly add all its digits until the result has only ...
- 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 ...
随机推荐
- 当使用junit4 对spring框架中controller/service/mapper各层进行测试时,需要添加的配置
@RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @ContextConfiguration(locations = {&quo ...
- day06-08面向对象的三大特性
一.继承 1.1什么是继承?继承是一种创建新类的方式,在python中,新建的类可以继承一个或多个父类,父类又可称为基类或超类,新建的类称为派生类或子类python中类的继承分为:单继承和多继承 cl ...
- JS 100元购物卡,牙刷5元,香皂2元、洗发水15元 100元正好花完有多少种可能
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 【BZOJ1367】【Baltic2004】sequence - 可合并堆
题意: 题解: 其实这是道水题啦……只不过我没做过而已 先考虑构造不严格递增序列,考虑原序列中的一段下降区间,显然区间中的$z$全取中位数最优: 那么可以把原序列拆成很多个下降序列,从头到尾加入原序列 ...
- Context - React跨组件访问数据的利器
Context提供了一种跨组件访问数据的方法.它无需在组件树间逐层传递属性,也可以方便的访问其他组件的数据 在经典的React应用中,数据是父组件通过props向子组件传递的.但是在某些特定场合,有些 ...
- 数据库优化一般思路(PLSQL、Navicat)
SQL执行过程: 1.执行SQL时,sql解析引擎会被启动 2.数据类型和数据库表定义的数据类型不一致,数据库引擎会自动转化 3.数据库表定义了多个索引,sql引擎会帮你选择最优的一个 4.数据库引擎 ...
- 打造一个全命令行的Android构建系统
IDE都是给小白程序员的,大牛级别的程序员一定是命令行控,终端控,你看大牛都是使用vim,emacs 就一切搞定” 这话说的虽然有些绝对,但是也不无道理,做开发这行要想效率高,自动化还真是缺少不了命令 ...
- myeclipse集成svn
svn安装 这个我在博客中的代码管理里面有些,也是一直next.svn代码管理版本号管理器安装好之后. myeclipse的svn插件 方法一: 然后配置MyEclipse的SVN插件,将插件下载下来 ...
- do while 循环和while循环的差别
do while 循环和while循环的差别 1.do while循环是先运行循环体,然后推断循环条件,假设为真,则运行下一步循环,否则终止循环. while循环是先推断循环条件,假设条件为真则 ...
- pandas深入理解
Pandas是一个Python库,旨在通过“标记”和“关系”数据以完成数据整理工作,库中有两个主要的数据结构Series和DataFrame In [1]: import numpy as np In ...