题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1018

解题报告:输入一个n,求n!有多少位。

首先任意一个数 x 的位数 = (int)log10(x) + 1;

所以n!的位数 = (int)log10(1*2*3*.......n) + 1;

= (int)(log10(1) + log10(2) + log10(3) + ........ log10(n)) + 1;

 #include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<queue>
using namespace std;
const int maxn = +;
double ans[maxn]; double dabiao(int n)
{
double temp = ;
for(int i = ;i <= n;++i)
temp += log10((double)i);
return temp;
}
int main()
{
int T,n;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
printf("%d\n",(int)dabiao(n) + );
}
return ;
}

最新文章

  1. 【JS基础】DOM操作
  2. 基于canvas的陈列订货的分析
  3. linux下的audit服务
  4. 初探YAML
  5. dip的全称
  6. TFSF边界条件
  7. 两个一样的tomcat不能同时启动解决方法
  8. Android下的Linux指令集
  9. NPOI导出多张图片到Excel
  10. 各种加密解密函数(URL加密解密、sha1加密解密、des加密解密)
  11. 自己编译的openwrt在开机时一直打印jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found...的错误提示
  12. C++ 常量类型 const 详解
  13. 一起来学linux:用户与用户组
  14. 转:Java IO流学习总结
  15. CSV导出大量数据
  16. Spring 组成
  17. cordova文件传输系统插件使用:cordova-plugin-file-transfer
  18. BN和滑动平均
  19. Python第一篇-简介和入门
  20. 让node支持es模块化(export、import)的方法

热门文章

  1. Windows Phone8 中如何引用 SQLite 数据库
  2. 去除a标签单击后的虚线框
  3. android之SQLlite操作
  4. 温故知新---重读C#InDepth(一)
  5. Nodejs学习笔记(六)--- Node.js + Express 构建网站预备知识
  6. Oracle中新增表代码
  7. 如何解决mysql数据库X小时无连接自动关闭
  8. C++ 11 线程的同步与互斥
  9. 【ZOJ 3897】Candy canes//Fiddlesticks
  10. 使用属性表:VS2013上配置OpenCV