UVA1185 Big Number
题目大意:求十进制下x!的位数
这题其实就是要求\(\lg\)函数值的前缀和啊
对于一个数x,若\(\lg x=y\),则其位数为\(\lfloor y+1 \rfloor\)
然后对于对数,我们有\(\lg \prod_{i=1}^x i= \sum_{i=1}^x \lg i\)
预处理前缀和之后在线\(\Theta(1)\)回答询问即可
#include"cstdio"
#include"cstring"
#include"iostream"
#include"algorithm"
#include"cmath"
using namespace std;
const int MAXN=1e7+5;
const double eps=1e-8;
double lg[MAXN];
int tp[MAXN];
int T;
int main()
{
for(int i=1;i<=1e7;++i) lg[i]=lg[i-1]+log10(i);
for(int i=1;i<=1e7;++i) tp[i]=lg[i]+1;
scanf("%d",&T);
while(T--){
int x;scanf("%d",&x);
printf("%d\n",tp[x]);
}return 0;
}
UVA1185 Big Number的更多相关文章
- 「UVA1185」Big Number 解题报告
UVA1185 Big Number In many applications very large integers numbers are required. Some of these appl ...
- JavaScript Math和Number对象
目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ...
- Harmonic Number(调和级数+欧拉常数)
题意:求f(n)=1/1+1/2+1/3+1/4-1/n (1 ≤ n ≤ 108).,精确到10-8 (原题在文末) 知识点: 调和级数(即f(n))至今没有一个完全正确的公式, ...
- Java 特定规则排序-LeetCode 179 Largest Number
Given a list of non negative integers, arrange them such that they form the largest number. For exam ...
- Eclipse "Unable to install breakpoint due to missing line number attributes..."
Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统 ...
- 移除HTML5 input在type="number"时的上下小箭头
/*移除HTML5 input在type="number"时的上下小箭头*/ input::-webkit-outer-spin-button, input::-webkit-in ...
- iOS---The maximum number of apps for free development profiles has been reached.
真机调试免费App ID出现的问题The maximum number of apps for free development profiles has been reached.免费应用程序调试最 ...
- 有理数的稠密性(The rational points are dense on the number axis.)
每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.
- [LeetCode] Minimum Number of Arrows to Burst Balloons 最少数量的箭引爆气球
There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided ...
随机推荐
- rdlc报表函数
字符串函数 使用串联运算符和 Visual Basic 常量可将多个字段组合在一起.以下表达式返回两个字段,它们分别位于同一文本框的不同行中: 复制代码 =Fields!FirstName. ...
- Spark累加器
spark累计器 因为task的执行是在多个Executor中执行,所以会出现计算总量的时候,每个Executor只会计算部分数据,不能全局计算. 累计器是可以实现在全局中进行累加计数. 注意: 累加 ...
- Vue中引入jquery方法
vue-cli webpack 引入jquery 今天费了一下午的劲,终于在vue-cli 生成的工程中引入了jquery,记录一下.(模板用的webpack) 首先在package.json里的 ...
- error occurred during initialization of vm
虚拟机无法进行如下分配 : -Xmx2048m -XX:MaxPermSize=512m 原因是我的老爷机总共内存只有3G: settings - > 搜索VM ->找到Compiler ...
- mysql数据库使用脚本实现分库备份过程
一条命令解决分库分表备份: [root@db01 data]# mysql -uroot -p123456 -e "show databases;"|egrep -v " ...
- 贪心--cf、education62-C
cf-Education 62-C 题目 C. Playlist time limit per test 2 seconds memory limit per test 256 megabytes i ...
- 【es6】数组扩展
只有一个参数,为数组中的值.
- 如何自己编译生成hadoop的eclipse插件,如hadoop-eclipse-plugin-2.6.0.jar
不多说,直接上干货! 如何自己编译生成Eclipse插件,如hadoop-eclipse-plugin-2.6.0.jar 一.相关软件的安装和配置 (一)JDK的安装和配置 Jdk 1.7*安装并配 ...
- HttpClient使用详细教程
Http协议的重要性相信不用我多说了,HttpClient相比传统JDK自带的URLConnection,增加了易用性和灵活性(具体区别,日后我们再讨论),它不仅是客户端发送Http请求变得容易,而且 ...
- hadoop ——HDFS存储
一.HDFS概念 二.HDFS优缺点 三.HDFS如何存储 一.HDFS概念 HDFS(Hadoop Distributed File System)是Hadoop项目的核心子项目,是分布式计算中数据 ...