uva 10916 Factstone Benchmark
来源:互联网 发布:孙悟空与哪吒知乎 编辑:程序博客网 时间:2024/05/18 15:03
利用对数的性质
#include <stdio.h>#include <math.h>double a[260000];int b[260000];void init(){int i;for(i=1; i<260000; i++){a[i] = a[i-1] + log((double)i)/log(2.0);}for(i=1; i<260000; i++){b[i] = floor(a[i]) + 1;}}void func(double bits){int l, r, m;int target = (int)bits;l = 1; r = 259999;while(1){m = (l+r)/2;if(b[m]<=target && target<b[m+1]){break;}else if(target < b[m]){r = m - 1;}else{l = m + 1;}}//printf("target=%d b[m]=%d b[m+1]=%d a[m]=%lf a[m+1]=%lf\n", target, b[m], b[m+1], a[m], a[m+1]);printf("%d\n", m);}int main(void){int year;init();while(1){scanf("%d", &year);if(0 == year)break;func( pow(2.0,(year-1960)/10) *4 );}return 0;}
- UVa 10916 Factstone Benchmark
- uva 10916 Factstone Benchmark
- UVA 10916 - Factstone Benchmark
- UVa 10916 - Factstone Benchmark
- uva 10916 - Factstone Benchmark
- uva-10916 - Factstone Benchmark
- Uva 10916 - Factstone Benchmark
- uva 10916 - Factstone Benchmark
- UVa 10916 - Factstone Benchmark
- UVA 10916 Factstone Benchmark
- uva 10916 Factstone Benchmark
- UVa 10916 Factstone Benchmark
- UVa 10916 - Factstone Benchmark
- UVa 10916 - Factstone Benchmark
- UVa 10916 - Factstone Benchmark
- UVa 10916 - Factstone Benchmark
- UVA 10916 Factstone Benchmark
- UVA - 10916 Factstone Benchmark
- Linux进程与线程学习随笔
- c代码反汇编,观察堆栈工作原理
- libcurl部分总结
- Android输入输出机制之来龙去脉之前生后世
- 基于JTBC的装修公司网站
- uva 10916 Factstone Benchmark
- 【每天一个Linux命令】20. Linux中的拷贝命令cp
- 将二叉搜索树转换成双向链表
- org.apache.struts2.impl.StrutsActionProxy.getErrorMessage(StrutsActionProxy.java:69)
- 多线程服务器的适用场合
- Java_xml_SAX解析xml
- sysbench 0.5 性能测试工具使用手册
- TortoiseGit的密钥
- 《多线程服务器的适用场合》例释与答疑