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 ...
随机推荐
- kernel对NTP的API,系统调用函数
kenrel API for NTP kernel 提供两个API(即系统调用 system call)给应用程序NTP,去校准kernel system clock Kernel Applicati ...
- 我的第一个 Windows 窗口程序(1)
一般来说,构建一个 Windows 程序可以分为如下几个步骤: 定义窗口类(WNDCLASS) 注册窗口类(RegisterClass) 创建窗口(CreateWindow) 更新显示窗口(Updat ...
- Nginx学习(1)--- 介绍与安装
1.基础介绍 常用功能 1.HTTP服务 动静分离.WEB缓存.虚拟主机设置.URL Rewrite 2.负载均衡 3.反向代理 4.正向代理 5.邮件服务器 优点 高扩展.高可用.支持高并发.低资源 ...
- 运用cat EOF添加文件
[root@fyc14 nginx1]# cat <<EOF > /etc/yum.repos.d/nginx.repo> [nginx]> name=nginx rep ...
- java深入的单例模式
在GoF的23种设计模式中,单例模式是比较简单的一种.然而,有时候越是简单的东西越容易出现问题.下面就单例设计模式详细的探讨一下. 所谓单例模式,简单来说,就是在整个应用中保证只有一个类的实例存在 ...
- Github+Jekyll 搭建个人网站详细教程
GitHub搭建个人网站,大家在网上一搜能搜到一大把的教程,但是大部分都讲的差不多,并不能满足自己想搭建的网站详细需求.我之前在搭建本站的时候也是查了较多资料,学习了下jekyll语法,参考了几个主题 ...
- auto-boxing, uboxing,以及缓存问题
package chengbaoDemo; public class Test02 { public static void main(String[] args) { Integ ...
- Elasticsearch 7.0 正式发布,盘他!
Elastic{ON}北京分享了Elasticsearch7.0在Speed,Scale,Relevance等方面的很多新特性. 比快更快,有传说中的那么牛逼吗?盘他! 通过本文,你能了解到: Ela ...
- Erlang语言入门
Erlang语言入门 下载Erlang,http://www.erlang.org/downloads 安装之后开始菜单中有Erlang图标,打开之后是Erlang Shell,可以定制喜欢的颜色和字 ...
- NAT&Port Forwarding&Port Triggering
NAT Nat,网络地址转换协议.主要功能是实现局域网内的本地主机与外网通信. 在连接外网时,内部Ip地址须要转换为网关(一般为路由器Ip地址)(port号也须要对应的转换) ...