问题陈述:

  杭州电子科技大学 HANGZHOU DIANZI UNIVERSITY Online Judge Problem - 1018

问题解析:

  公式一:

    n! = 10^m => lg(10^m) = lg(n!) => m = lg(n) + lg(n-1) + lg(n-2) + ... + lg1;

    所以digits = (int)m + 1;

 公式二:stirling公式

    n! ≈ √2PIn(n/e)n                         

    化简:lg(n!) = 1/2lg(2*PI*n) + nlg(n/e);

代码详解:

I:

 #include <iostream>
#include <cstdio>
#include <cmath> using namespace std; int main()
{
int i, n, t, digits;
double m;
cin >> n;
while(n--) {
m = ;
cin >> t;
for(i=; i<=t; i++) {
m += log10(i*1.0);
}
digits = (int)m + ;
cout << digits << endl;
}
return ;
}

II:

 #include <iostream>
#include <cstdio>
#include <cmath> using namespace std; int main()
{
int n, t, digits;
double PI = acos(double(-));
double e = exp(double());
cin >> n;
while(n--) {
cin >> t;
digits = (int)(0.5*log10(*PI*t) + t*log10(t/e)) + ;
cout << digits << endl;
}
return ;
}

转载请注明出处:http://www.cnblogs.com/michaelwong/p/4287232.html

    

Big Number的更多相关文章

  1. JavaScript Math和Number对象

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  9. [LeetCode] Number of Boomerangs 回旋镖的数量

    Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of po ...

  10. [LeetCode] Number of Segments in a String 字符串中的分段数量

    Count the number of segments in a string, where a segment is defined to be a contiguous sequence of ...

随机推荐

  1. 处理PHP中字符串的常用操作及函数

    1. 确定一个字符串的长度 这是最为常见和基础的例子,对于确定一个字符串的长度,我们应该使用strlen()函数,比如要获取下面字符串$text 的长度: $text = "sunny da ...

  2. SCSI接口图文详解

    目前存储设备的接口有五大类:IDE.SCSI.USB,并行口,串口,其中并行口与串口的速度非常慢,不提也罢,最主要的就是IDE,usb,SCSI.IDE(Integrated Drive Electr ...

  3. 360极速浏览器 HTML5实验室

    360极速浏览器 HTML5实验室 HTML5 实验室

  4. 几个简单的css设置问题:div居中,ul li不换行 ,内容超出自动变省略号等

    1  div在页面居中的问题 1)position值为relative时(相对定位),css设置属性margin:0 auto;(0 auto,表示上下边界为0,左右则根据宽度自适应相同值,即居中)即 ...

  5. convertView

    [convertView] 参考:https://zhidao.baidu.com/question/423895201122905772.html

  6. Spring的AOP2

    本文是<AOP 那点事儿>的续集. 在上篇中,我们从写死代码,到使用代理:从编程式 Spring AOP 到声明式 Spring AOP.一切都朝着简单实用主义的方向在发展.沿着 Spri ...

  7. Unity 屏幕震动效果实现

    要实现震屏效果其实并不难,所谓的震屏在PC端可以简单地理解为相机(MainCamera)的抖动. 代码实现如下: using UnityEngine; using System.Collections ...

  8. php 添加 redis 扩展模块

    由于PHP源码中并未有redis的文件,所以需要自己下载. 下载地址: http://pecl.php.net/get/redis-2.2.5.tgz [root@study package]# ta ...

  9. 1. 用U盘安装Centos6.5 + Win7 双系统

    一. 用U盘安装Centos6.5 + Win7 双系统 准备工作:U盘(8G).需要安装的Centos6.5系统(64bit).EasyBCD(用来修复引导,否则开机只有一个系统).         ...

  10. css 图片 圆形显示区域

    css 图片 圆形显示区域 css 和 div 实现 方形图片 圆形显示 点击下载