POJ 1423 Big Number
题意:求n阶乘的位数。
解法:斯特林公式,,然后取log10就是位数了,因为精度问题需要化简这个式子,特判1。
代码:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<time.h>
#include<stdlib.h>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#define LL long long
using namespace std;
const double pi = acos(-1.0);
const double e = 2.718281828459;
int main()
{
int T;
scanf("%d", &T);
while(T--)
{
int n;
scanf("%d", &n);
if(n == 1)
{
puts("1");
continue;
}
printf("%d\n", (int)ceil(0.5 * log10(2.0 * pi * n) + log10((double)n) * n - log10(e) * n));
}
return 0;
}
POJ 1423 Big Number的更多相关文章
- poj 2104 K-th Number 主席树+超级详细解释
poj 2104 K-th Number 主席树+超级详细解释 传送门:K-th Number 题目大意:给出一段数列,让你求[L,R]区间内第几大的数字! 在这里先介绍一下主席树! 如果想了解什么是 ...
- poj 2104 K-th Number(主席树,详细有用)
poj 2104 K-th Number(主席树) 主席树就是持久化的线段树,添加的时候,每更新了一个节点的线段树都被保存下来了. 查询区间[L,R]操作的时候,只需要用第R棵树减去第L-1棵树就是区 ...
- POJ 1423:Big Number 求N的阶乘的长度 斯特林公式
Big Number Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 27027 Accepted: 8626 Descr ...
- [划分树] POJ 2104 K-th Number
K-th Number Time Limit: 20000MS Memory Limit: 65536K Total Submissions: 51732 Accepted: 17722 Ca ...
- POJ 2014.K-th Number 区间第k小 (归并树)
K-th Number Time Limit: 20000MS Memory Limit: 65536K Total Submissions: 57543 Accepted: 19893 Ca ...
- SPOJ MKTHNUM & POJ 2104 - K-th Number - [主席树模板题]
题目链接:http://poj.org/problem?id=2104 Description You are working for Macrohard company in data struct ...
- POJ 2104 K-th Number 主席树(区间第k大)
题目链接: http://poj.org/problem?id=2104 K-th Number Time Limit: 20000MSMemory Limit: 65536K 问题描述 You ar ...
- POJ P2104 K-th Number
You are working for Macrohard company in data structures department. After failing your previous tas ...
- POJ 1019:Number Sequence 二分查找
Number Sequence Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 36013 Accepted: 10409 ...
随机推荐
- 你所不知道的黑客工具之 EK 篇
EK(Exploit kits)是指一套利用恶意软件感染用户电脑发起攻击的黑客工具,时下最著名的有 Angler EK.Fiesta EK.Hanjuan EK.Nuclear EK.Neutrino ...
- hdu 1757 A Simple Math Problem (矩阵快速幂,简单)
题目 也是和LightOJ 1096 和LightOJ 1065 差不多的简单题目. #include<stdio.h> #include<string.h> #include ...
- ubuntu安装hadoop2.6
一:单机版 1.sudo gedit ~/.bashrc 加入JDK路径 #HADOOP VARIABLES START export JAVA_HOME=/usr/lib/jvm/java-1.7. ...
- 使用 C# 对文件进行压缩和解压
C#中对文件压缩和可以使用两个类: GZipStream 类 此实例分为几个模块,分别为: 压缩函数: /// <summary> /// 压缩文件 /// </summary> ...
- 【转】Java读取文件方法大全
本文转自:http://www.cnblogs.com/lovebread/archive/2009/11/23/1609122.html#undefined 目录: 按字节读取文件内容 按字符读取文 ...
- spring 与 CXF 整合 webservice 出现error “Unable to locate Spring NamespaceHandler for XML schema namespace” 总结
我试了多个版本的spring 发现 出现error : Unable to locate Spring NamespaceHandler for XML schema namespace 并非都是sp ...
- 使用Css截取字符串
white-space:nowrap; /* 禁止自动换行 */ overflow:hidden; /* 隐藏溢出的内容 */ text-overflow:ellipsis; /* 溢出文本使用... ...
- 缓存初解(三)---Spring3.0基于注解的缓存配置+Ehcache和OScache
本文将构建一个普通工程来说明spring注解缓存的使用方式,关于如何在web应用中使用注解缓存,请参见: Spring基于注解的缓存配置--web应用实例 一.简介 在spring的modules包中 ...
- SSL/TLS/WTLS原理
一 前言 首先要澄清一下名字的混淆:1 SSL(Secure Socket Layer)是netscape公司设计的主要用于web的安全传输协议.这种协议在WEB上获得了广泛的应用.2 IETF(ww ...
- js捕捉浏览器关闭事件-兼容几乎所有浏览器
很多时候我们都在困扰,如何捕获浏览器关闭事件,网上虽然有很多方法,但都不理想,后来终于找到了一个很好地实现方法,大家可以试试哦,支持几乎所有的浏览器 <script type="tex ...