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 ...
随机推荐
- Python连接Neo4j工具比较 Neo4j Driver、py2neo
Python有许多可以连接Neo4j的库和工具,以下是一些常用的: Neo4j Driver for Python 这是官方提供的Python驱动程序,它使用Cypher查询语言与Neo4j数据库进行 ...
- freeswitch sofia协议栈调试
概述 freeswitch是一款简单好用的VOIP开源软交换平台. fs内部使用sofia的sip协议栈,本文介绍如何调试跟踪sofia协议栈. 环境 centos:CentOS release 7 ...
- KRPANO资源分析工具下载720THINK全景图
提示:目前分析工具中的全景图下载功能将被极速全景图下载大师替代,相比分析工具,极速全景图下载大师支持更多的网站(包括各类KRPano全景网站,和百度街景) 详细可以查看如下的链接: 极速全景图下载大师 ...
- Oracle为表添加约束
转载自:https://blog.csdn.net/qq_38662525/article/details/94192475 创建一个学生表和院系表:院系表为主表,学生表为从表 create ta ...
- dedebiz友情链接样式修改
文件位置 /system/taglib/flink.lib.php 45行位置 根据自己需求修改就行
- C#学习笔记——变量、常量和转义字符
变量 变量是存储数值的容器,是一门程序语言的最基础的部分. 不同的变量类型可以存储不同类型的数值. 种类: 在C#种一共有14种变量: 有符号类型4种 无符号类型4种 浮点数3种 特殊类型(char ...
- MySQL PXC 集群运维指南
目录 一.PXC方案概述 二.PXC基础知识 三.PXC节点的配置安装 四.PXC节点的上线与下线 五.其他 一.PXC方案概述 Percona XtraDB Cluster (PXC) 是一个完全开 ...
- NW排错
fist date VM备份失败时: NW server上(linux): > nsradmin >p type : nsr recover > cd /nsr/logs >n ...
- 手写商用Java虚拟机HotSpot,疯狂磨砺技术中
在当前Java行业激烈竞争的形式下,唯有掌握技术,心中才不能慌.在多年前,我就开始苦练底层技术,但是眼看百遍也不如手过一遍,所以我打算把虚拟机的精华实现部分用手敲出来,这个过程注定不会轻松,但是心态不 ...
- JS个人总结(1)
1. html页面引入js文件优先使用引入外部js文件. 2. 如果在html页面里使用<script></script>,则把js内容放在html内容下面,也就是</b ...