博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 1018 Big Number 数学结论
阅读量:4566 次
发布时间:2019-06-08

本文共 1277 字,大约阅读时间需要 4 分钟。

Big Number

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 34084    Accepted Submission(s): 16111

Problem Description
In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of digits in the factorial of the number.
 

 

Input
Input consists of several lines of integer numbers. The first line contains an integer n, which is the number of cases to be tested, followed by n lines, one integer 1 ≤ n ≤ 10
7 on each line.
 

 

 

Output
The output contains the number of digits in the factorial of the integers appearing in the input.
 

 

Sample Input
2 10 20
 

 

Sample Output
7 19
 

 看到这个题就像用java写,结果超时。其实这是一道规律题:

 N!的长度=log10(i)【i:2~n】+1;

然后就简单了。

#include
#include
#include
using namespace std;int main(){ int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); double tmp=0; for(int i=2;i<=n;i++) tmp+=log10(i+0.0); int ans =(int)tmp+1; printf("%d\n",ans); } return 0;}
View Code

 

转载于:https://www.cnblogs.com/superxuezhazha/p/5539502.html

你可能感兴趣的文章
luogu 1314 聪明的质检员
查看>>
[转载]求职者防骗必读!楼主亲身经历告诉你岗前培训多么不靠谱而且违法!
查看>>
Hibernate内存溢出分析一例
查看>>
基于Axis1.4的webservice接口开发(接口调用)
查看>>
Hive内置函数详解
查看>>
【转】MyEclipse快捷键大全
查看>>
IT职业技能图谱10--Hadoop家族技能图谱
查看>>
Java - 反射(1)
查看>>
控制台中显示执行的Sql语句
查看>>
Linux(Centos7)下搭建SVN服务器
查看>>
安卓开发的Tasks and Back Stack
查看>>
Ansi,UTF8,Unicode编码
查看>>
原子变量的性能问题
查看>>
Sybase PowerDesigner 15.0 完美版+特别文件
查看>>
快速傅立叶之二
查看>>
cetos 6.3 安装 apache+mysql+php
查看>>
js编写简单的贪吃蛇游戏
查看>>
2018/12/01 一个64位操作系统的实现 第四章 导入kernel.bin(4)
查看>>
如何在windows xp professional安装iis的解决方法
查看>>
抽象类和接口
查看>>