题意:求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;
}

  

最新文章

  1. GeoServer中WMS、WFS的请求规范
  2. nginx.conf中配置laravel框架站点
  3. HTML基础篇之HTML基本元素
  4. 转载:[转]如何学好3D游戏引擎编程
  5. cygwin-安装断点续传
  6. 利用反射和ResultSetMetaData实现DBUtils的基本功能
  7. IOS 中的KVO模式 观察者模式
  8. 北邮网关登录python脚本
  9. 未能从程序集“System.ServiceModel,xxx”中加载类型“System.ServiceModel.Activation.HttpModule”。
  10. Delphi中的内存对齐 与 Packed关键字
  11. [转]hibernate三种状态详解
  12. Spring Boot自定义Banner
  13. 我的 FPGA 学习历程(08)—— 实验:点亮单个数码管
  14. Linux 获取设备树源文件(DTS)里描述的资源【转】
  15. 为什么IT运维工程师要学习Linux系统
  16. Echart示例
  17. 苹果copy等其他的英文改成中文
  18. grafana+influxdb+telegraf监控服务器cpu,内存和硬盘
  19. WEB接口测试之Jmeter接口测试自动化 (二)
  20. Django 中文显示

热门文章

  1. lintcode : 二叉树的最小深度
  2. hdu 3863 No Gambling
  3. 毕向东JAVA视频视频讲解(第八课)
  4. Linux资源监控命令/工具(网络)
  5. HTML5 增强的页面元素
  6. DOS命令 Net config server Net config workstation
  7. IDEA快速光标跳转
  8. JAVA+ Proxool+ SQLserver 2008 “signer information does not match signer information of other classes in the same package”
  9. NSRect
  10. 区分int a() 和 int a