hdu 1141 Factstone Benchmark(数学:计算)
来源:互联网 发布:unix网络编程pdf下载 编辑:程序博客网 时间:2024/04/28 10:08
所要求的是最大的n使得n! < 2^x
则找到log(n!) < x*log(2)即可
代码如下:
#include <math.h>#include <stdio.h>#define MAXN 50int n, i, j, a, b[MAXN];double sum;void init() { for(i=0; i<25; ++i) { a = pow(2, i+2); sum = 0.0;//浮点数 for(j=1; ; j++) { sum += log(j); if(a*log(2) <= sum) { b[i] = j; break; } } }}int main(void) { init(); while(scanf("%d", &n), n) { printf("%d\n", b[(n-1960)/10]-1); } return 0;}
0ms代码如下:
#include <math.h>#include <stdio.h>int a[] = {3, 5, 8, 12, 20, 34, 57, 98, 170, 300, 536, 966, 1754, 3210, 5910, 10944, 20366, 38064, 71421, 134480, 254016};int n;int main(void) { while(scanf("%d", &n), n) { printf("%d\n", a[(n-1960)/10]); } return 0;}
0 0
- hdu 1141 Factstone Benchmark(数学:计算)
- 【数学 对数】HDU 1141 Factstone Benchmark
- 【水题-数学】 HDU 1141 Factstone Benchmark
- HDU 1141 Factstone Benchmark (数学)
- hdu 1141 Factstone Benchmark
- HDU 1141 Factstone Benchmark
- hdu 1141 Factstone Benchmark
- hdu 1141 Factstone Benchmark
- hdu 1141 Factstone Benchmark
- HDOJ HDU 1141 Factstone Benchmark
- ACM--数学--HDOJ 1141--Factstone Benchmark--水
- poj2661 Factstone Benchmark 数学
- HDU 1141 Factstone Benchmark 对数乱搞
- HDU1141 Factstone Benchmark(数学)
- hdoj-1141-Factstone Benchmark
- hdu 1141 Factstone Benchmark 数论水题,,阶乘用斯特林公式
- UVA - 10916 Factstone Benchmark(数学)
- 杭电1141 Factstone Benchmark
- Atitit.java c++指针使用总结O7
- U盘安装网卡驱动
- HDOJ-1076 An Easy Task
- cvFindStereoCorrespondenceBM 结果是否要除以16的问题~
- Handler机制
- hdu 1141 Factstone Benchmark(数学:计算)
- 面向对象——一起来复习委托与事件!
- Linux内核中的红黑树
- Ruby.on.Rails.Web开发之旅-3-在ruby中使用面向对象编程
- 基于QML2.0的View之TabView
- 全排列问题的STL用法(next_permutation类)
- 初识dll,在VS2010平台上创建并使用dll
- Windows下数据类型的字节数
- 记一次离奇的TNS-12545 TNS-12560 TNS-00515