题目大意:求十进制下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的更多相关文章

  1. 「UVA1185」Big Number 解题报告

    UVA1185 Big Number In many applications very large integers numbers are required. Some of these appl ...

  2. JavaScript Math和Number对象

    目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ...

  3. Harmonic Number(调和级数+欧拉常数)

    题意:求f(n)=1/1+1/2+1/3+1/4-1/n   (1 ≤ n ≤ 108).,精确到10-8    (原题在文末) 知识点:      调和级数(即f(n))至今没有一个完全正确的公式, ...

  4. Java 特定规则排序-LeetCode 179 Largest Number

    Given a list of non negative integers, arrange them such that they form the largest number. For exam ...

  5. Eclipse "Unable to install breakpoint due to missing line number attributes..."

    Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统 ...

  6. 移除HTML5 input在type="number"时的上下小箭头

    /*移除HTML5 input在type="number"时的上下小箭头*/ input::-webkit-outer-spin-button, input::-webkit-in ...

  7. 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.免费应用程序调试最 ...

  8. 有理数的稠密性(The rational points are dense on the number axis.)

    每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.

  9. [LeetCode] Minimum Number of Arrows to Burst Balloons 最少数量的箭引爆气球

    There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided ...

随机推荐

  1. ArrayList 和 Vector 的区别

    这两个类都实现了 List 接口( List 接口继承了 Collection 接口),他们都是有序集合,即存储在这两个集合中的元素的位置都是有顺序的,相当于一种动态的数组,我们以后可以按位置索引号取 ...

  2. day 09 课后作业

    # -*- coding: utf-8 -*-# @Time : 2018/12/28 14:25# @Author : Endless-cloud# @Site : # @File : 08 课后作 ...

  3. 人工鱼群算法超详细解析附带JAVA代码

    01 前言 本着学习的心态,还是想把这个算法写一写,给大家科普一下的吧. 02 人工鱼群算法 2.1 定义 人工鱼群算法为山东大学副教授李晓磊2002年从鱼找寻食物的现象中表现的种种移动寻觅特点中得到 ...

  4. orcal创建序列

    CREATE SEQUENCE flowjobseq --序列名INCREMENT BY 1 -- 每次加几个 START WITH 2000 -- 从1开始计数 NOMAXVALUE -- 不设置最 ...

  5. ArcGis10.2破解教程

    ArcGis10.2下载地址: https://pan.baidu.com/s/15s5ki_8gf0_732br6h43Hw 破解步骤: 1.完成License Manager的安装. 2.将破解文 ...

  6. nRF51822EK_PRO

    ARMCC5LIB = C:\Keil\ARM\ARMCC\lib dd if=/dev/zero of=tmp.500M bs=500M count=1 Developer Home

  7. webpack原理探究 && 打包优化

    在做vue项目和react项目时,都用到了webpack.webpack帮助我们很好地提高了工作效率,但是一直以来没有对其原理进行探究,略有遗憾. 因为使用一个工具,能够深入了解其原理才能更好地使用. ...

  8. java容器类1:Collection,List,ArrayList,LinkedList深入解读

    1. Iterable 与 Iterator Iterable 是个接口,实现此接口使集合对象可以通过迭代器遍历自身元素. public interface Iterable<T> 修饰符 ...

  9. 拖进Xshell终端窗口文件上传

    XShell已经内置rz 直接从Windows拖文件进去终端 http://www.jb51.net/LINUXjishu/163820.html 借助securtCRT,使用linux命令sz可以很 ...

  10. 【Maven学习】远程仓库的配置

    很多情况下,默认的中央仓库无法满足项目的需求,我们可能需要配置新的远程仓库,此时我们可以这样配置: <repository> <id>java-net</id> & ...