HDU 1108
Big Number
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 38440 Accepted Submission(s): 18627Problem DescriptionIn 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.InputInput 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 ≤ 107 on each line.OutputThe output contains the number of digits in the factorial of the integers appearing in the input.Sample Input21020Sample Output719
t+=log10(i*1.00);
sum=int(t)+1;
这样就很好的求出位数了。
代码:
1 #include<iostream>
2 #include<stdio.h>
3 #include<string.h>
4 #include<cmath>
5 #include<math.h>
6 using namespace std;
7 int main(){
8 int T;
9 cin>>T;
10 while(T--){
11 int n;
12 scanf("%d",&n);
13 int sum=0;
14 double t=0.0;
15 for(int i=1;i<=n;i++){
16 t+=log10(i*1.00);
17 }
18 sum=int(t)+1;
19 cout<<sum<<endl;
20 }
21 return 0;
22 }
HDU 1108的更多相关文章
- HDU 1108 最小公倍数
#include <cstdio> int gcd(int a,int b) { ) return a; else return gcd(b,a%b); } int main() { in ...
- HDU 1222 - Wolf and Rabbit & HDU 1108 - [最大公约数&最小公倍数]
水题,只是想借此记一下gcd函数的模板 #include<cstdio> int gcd(int m,int n){return n?gcd(n,m%n):m;} int main() { ...
- HDU 1108.最小公倍数-辗转相除法
最小公倍数 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
- HDU题解索引
HDU 1000 A + B Problem I/O HDU 1001 Sum Problem 数学 HDU 1002 A + B Problem II 高精度加法 HDU 1003 Maxsu ...
- hdu 2503 1713 1108 最小公倍数&最大公约数
gcd模板: __int64 gcd(__int64 a,__int64 b) { retur b==0?a:gcd(b,a%b); } 1108: #include<iostream> ...
- ZOJ 1108 FatMouse's Speed (HDU 1160) DP
传送门: ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=108 HDU :http://acm.hdu.edu.cn/s ...
- ZOJ 1108 & HDU 1160 - FatMouse's Speed
题目大意:给你n只老鼠的体重w和速度s,让你找出最长的子序列使得w[i] < w[j] 且 s[i] > s[j] (i < j).求最长序列的长度并输出该序列. LIS(Longe ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- HDU 4422 The Little Girl who Picks Mushrooms(简单题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4422 题目大意:小姑娘背着5个包去山上采蘑菇,每座山上只能用一个背包采集.三个小精灵会要她3个背包,其 ...
- [转] HDU 题目分类
转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...
随机推荐
- Solidity-变量和数据类型[基本类型]
在solidity语言中,变量和数据类型分为三类:基本类型(bool.int.address等),复合类型(array.struct.mapping等)和特殊类型(enum.function.modi ...
- MySQL高级12-事务原理
一.事务概念 事务是一组操作的集合,他是一个不可分割的工作单位,事务会把所有操作作为一个整体一起向系统提交或者撤销请求操作,即这些操作要么同时成功,要么同时失败. 二.事务特性 原子性(Atomici ...
- Modbus转profinet网关连接位移计在1200程序控制案例
Modbus转profinet网关连接位移计在1200程序控制案例 本案例讲述了兴达易控Modbus转profinet网关(XD-MDPN100)连接现场用台达LD-E镭射位移计检测控制在1200PL ...
- Biwen.QuickApi代码生成器功能上线
[QuickApi("hello/world")] public class MyApi : BaseQuickApi<Req,Rsp>{} 使用方式 : dotnet ...
- LINUX线程之一次性初始化(PTHREAD_ONCE)
1.一次性初始化 在 Linux函数列表 中描述了Linux线程中的常用函数,这里详细讲解 pthread_once 函数的功能和使用. (1)为何有"一次性初始化概念"出现? 其 ...
- gestureRecognition
这段代码定义了一个名为 gestureRecognition 的函数,它用于识别手势并显示在摄像头或指定图像上.以下是对代码的详细注释:1. 初始化一个空字符串 ges,用于存储手势结果.如果 sel ...
- 高可用mongodb集群(分片+副本):性能测试
目录 ■ 为指定的库和表指定hash分片 ■ 测试模型,即workload模型 ■ 测试指标 ■ workload_s6 ■ 分片集群性能测试数据统计分析 ■ 测试结论 Yahoo! Cloud Se ...
- 如何在 Ubuntu上使用snap安装Docker
1 检查系统版本 具有sudo或root用户权限 2 安装 SNAP ctrl+alt+T 打开终端 运行以下命令以安装 SNAP sudo apt update sudo apt install s ...
- Emit 实体绑定源码开源,支持类以及匿名类绑定(原创)
动态实体绑定 主要有以下两种 1.表达式树构建委托 2.Emit构建委托 根据我的经验 Emit 代码量可以更少可以很好实现代码复用 Emit实践开源项目地址跳转 https://www.cnblog ...
- MySQL 高级(进阶) SQL 语句——其二
MySQL 高级(进阶) SQL 语句 视图 ---- CREATE VIEW ----视图,可以被当作是虚拟表或存储查询. 视图跟表格的不同是,表格中有实际储存数据记录,而视图是建立在表格之上的一个 ...