【HDOJ】1018 Big Number
数学题,还是使用log避免大数,但是不要忘记需要+1,因为0也是1位,log(100)= 2,但却是3位。
#include <stdio.h>
#include <math.h> int main() {
int case_n, n;
int i;
double sum; scanf("%d", &case_n); while (case_n--) {
scanf("%d", &n);
sum = 1.0f;
for (i=; i<=n; ++i)
sum += log10(i);
printf("%d\n", (int)sum);
} return ;
}
【HDOJ】1018 Big Number的更多相关文章
- 【HDOJ】3948 The Number of Palindromes
后缀数组求不重复回文子串数目.注意dp数组. /* 3948 */ #include <iostream> #include <sstream> #include <st ...
- 【HDOJ】4162 Shape Number
循环串的最小表示法. /* */ #include <iostream> #include <string> #include <map> #include < ...
- 【HDOJ】3006 The Number of set
数据量这么小,果断状态压缩+dp. /* 3006 */ #include <iostream> #include <string> #include <map> ...
- 【HDOJ】5179 beautiful number
DFS. /* 5179 */ #include <iostream> #include <algorithm> #include <map> #include & ...
- 【HDU】 1018 Big Number
大意就是求 : log10(n!) = log10(1 * 2 * 3 * .......*n) = log10(1) + log10(2) + ........+log10(n); 打表的话会ML ...
- 【转】oracle数据库NUMBER数据类型
原文:http://www.jb51.net/article/37633.htm NUMBER ( precision, scale)a) precision表示数字中的有效位;如果没有指定prec ...
- 【CF245H】Queries for Number of Palindromes(回文树)
[CF245H]Queries for Number of Palindromes(回文树) 题面 洛谷 题解 回文树,很类似原来一道后缀自动机的题目 后缀自动机那道题 看到\(n\)的范围很小,但是 ...
- 【BZOJ4026】dC Loves Number Theory 分解质因数+主席树
[BZOJ4026]dC Loves Number Theory Description dC 在秒了BZOJ 上所有的数论题后,感觉萌萌哒,想出了这么一道水题,来拯救日益枯竭的水题资源. 给 ...
- 【LeetCode】375. Guess Number Higher or Lower II 解题报告(Python)
[LeetCode]375. Guess Number Higher or Lower II 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://f ...
随机推荐
- 【html】【13】特效篇--下拉导航
html代码: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" ...
- JSON的基本格式以及与JavaScript之间的转换
JSON的基本格式以及与JavaScript之间的转换 近来,发现很多人写json格式的数据时,总是没有达到JSON的规范,虽然在语言要求不严格的情况下能够通过, 但是,难免会遇到这样那样的问题,到时 ...
- activemq spring 配置
Apache ActiveMQ是最流行和最强大的开源消息集成模式服务器.Apache ActiveMQ是速度快,支持多跨语言的客户端和协议,带有易于使用企业集成模式和许多先进的功能在充分支持JMS 1 ...
- HeadFirst设计模式-前言总结
1 鸭子抽象类 class Duck { quack(); swim(); virtual display()=0 }; 现在如果让鸭子能够飞 class Duck { quack(); swim() ...
- ThreadPoolExecutor 线程池的实现
ThreadPoolExecutor继承自 AbstractExecutorService.AbstractExecutorService实现了 ExecutorService 接口. 顾名思义,线程 ...
- js搜索框 js仿百度搜索 js下拉框 jQuery.Autocomplete使用
做了一个网站,需要根据文本框的输入模糊搜索数据库内容给出提示供用户选择,就找到了jQuery.Autocomplete 效果如下图: 该插件托管在github上,具体地址:https://github ...
- Mac下修改默认的Java版本
今天在安装Elicpse IDE的时候,发现提示安装的Java版本不支持,于是在官方去下载了Jre最新版本并安装,在安装完过后再次打开Elicpse发现提示还是不正确,如果用Google查询到一些资料 ...
- Redhat 6.5 x64 下载地址
http://ftp.okhysing.is/ftp/redhat/6.5/isos/x86_64/
- json在线校验
弄了一个在线校验,清爽无广告,欢迎大家收藏 http://www.zhhoney.com/
- hdu 2594 Simpsons’ Hidden Talents KMP应用
Simpsons’ Hidden Talents Problem Description Write a program that, when given strings s1 and s2, fin ...