POJ 1423 Big Number
2024-10-18 20:27:33
题意:求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;
}
最新文章
- GeoServer中WMS、WFS的请求规范
- nginx.conf中配置laravel框架站点
- HTML基础篇之HTML基本元素
- 转载:[转]如何学好3D游戏引擎编程
- cygwin-安装断点续传
- 利用反射和ResultSetMetaData实现DBUtils的基本功能
- IOS 中的KVO模式 观察者模式
- 北邮网关登录python脚本
- 未能从程序集“System.ServiceModel,xxx”中加载类型“System.ServiceModel.Activation.HttpModule”。
- Delphi中的内存对齐 与 Packed关键字
- [转]hibernate三种状态详解
- Spring Boot自定义Banner
- 我的 FPGA 学习历程(08)—— 实验:点亮单个数码管
- Linux 获取设备树源文件(DTS)里描述的资源【转】
- 为什么IT运维工程师要学习Linux系统
- Echart示例
- 苹果copy等其他的英文改成中文
- grafana+influxdb+telegraf监控服务器cpu,内存和硬盘
- WEB接口测试之Jmeter接口测试自动化 (二)
- Django 中文显示
热门文章
- lintcode : 二叉树的最小深度
- hdu 3863 No Gambling
- 毕向东JAVA视频视频讲解(第八课)
- Linux资源监控命令/工具(网络)
- HTML5 增强的页面元素
- DOS命令 Net config server Net config workstation
- IDEA快速光标跳转
- JAVA+ Proxool+ SQLserver 2008 “signer information does not match signer information of other classes in the same package”
- NSRect
- 区分int a() 和 int a