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 ...
随机推荐
- [NOI2005]维护数列_Splay
真的毫无算法可言,就是比谁的码力强罢了... Code: #include<stack> #include<cstdio> #include<algorithm> ...
- 用SufaceGO加微软全家桶做个遥控车(一)
作为一个dotnet技术的新手我是不好意思写帖子的,原因就是本人技术太水了,写出的帖子肯定会让人笑话.所以这次我是厚着脸皮写出这个帖子的,希望大佬们轻喷了.我的目标就是用SurfaceGo实现一个和我 ...
- JZOJ5804. 【2018.08.12提高A组模拟】简单的序列
性质:每个位置的前缀和必须大于0,总和=0.以此dp即可. #include <iostream> #include <cstdio> #include <cstring ...
- assound.conf
pcm.!dmix {type dmixipc_key 5678293ipc_key_add_uid yesslave {pcm "hw:0,0"period_time 0peri ...
- tp3.1 白板不报错
今天有碰上了这种情况, 一般记忆力好把刚才改动的地方恢复一下就好了,但是今天特殊原因编辑器不小心关了,也不知道把那里改坏了,一通乱找,也找不到.汗! 没办法,提交代码几面,用git看下改变的地方,是c ...
- Python docs
刚刚发现了Python好用的文档查询网页:Python docs,可以选择python版本查询,跟OpenCV docs很相似,很好用-
- NYOJ 589 糖果
糖果 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描写叙述 topcoder工作室的PIAOYIi超级爱吃糖果.如今他拥有一大堆不同种类的糖果.他准备一口气把它们吃完.但是 ...
- Github博客私人订制(一)
这是博客订制的第一步,简单博客的建立. (这里不做截图说明了,贴图实在是太累,有问题大家QQ私聊我) (一)创建Github账号 URL:https://github.com/ (二)登录Github ...
- 请用Java设计一个Least Recently Used (LRU) 缓存
LRU介绍:LRU是Least Recently Used的缩写,即最少使用页面置换算法,是为虚拟页式存储管理服务的, 思路介绍: 能够使用两个标准的数据结构来实现.Map和Queue.由于须要支持多 ...
- swift菜鸟入门视频教程-09-类和结构体
本人自己录制的swift菜鸟入门,欢迎大家拍砖,有什么问题能够在这里留言. 主要内容: 类和结构体对照 结构体和枚举是值类型 类是引用类型 类和结构体的选择 集合(collection)类型的赋值与复 ...