poj1423 打表
来源:互联网 发布:windows自带壁纸路径 编辑:程序博客网 时间:2024/05/15 03:55
如题:http://poj.org/problem?id=1423
while(N--)
{
1.输入n;(1-10^7)
2.输出n的阶乘的位数;
}
首先分析求数X的位数为log10 X下取整+1,C语言中log(10)函数只需包含头文件math.h
log10(n!)=log10(n*n-1*n-2*.....*1)=log10(n)+log10(n-1)+...log10(1);
因为需要输入多组数据,打表比较省时
#include<stdio.h>
#include<math.h>
#define MAXN 10000001
int weishu[MAXN];
int main()
{
double t=0;
for(int i=1;i<10000001;i++)
{
t+=log10(i);
weishu[i]+=(int)t+1;
}
int N;
scanf("%d",&N);
while(N--)
{
int n;
scanf("%d",&n);
printf("%d\n",weishu[n]);
}
return 0;
}
0 0
- poj1423 打表
- POJ1423
- poj1423
- poj1423
- poj1423
- POJ1423
- poj1423(排序)
- POJ1423- 数学
- poj1423 tmd公式
- POJ1423 与 HDOJ1018 BigNumber
- poj1423 Big Number
- 水题poj1423 解题报告
- poj1423 hdu1018 Big Number
- poj1423解题报告
- 重新走上ACM!poj1423
- poj1423(斯特林公式)
- 打表
- 打表
- Ubuntu下vncserver配置
- 行地址与列地址
- 第9周项目6-穷举法解决组合问题(1,2)
- 织梦DedeCMS搜索页支持arclist,sql等标签
- 第9周项目三星号图b
- poj1423 打表
- 一个集合的子集个数的计算方法
- C3P0在多线程下的maxPoolSize配置
- Android高仿百度地图公交与位置建议搜索(四)
- DedeCMS调用指定栏目不包含下级栏目的问题
- pat 1028
- struts2 访问Web元素的4种方法
- ios5 选择了ARC但是不使用ARC编译,-fno-objc-arc
- rails better than php ?