Factstone Benchmark
来源:互联网 发布:飞秋for mac 下载 编辑:程序博客网 时间:2024/05/21 09:19
Factstone Benchmark
大意:
根据所给的年份,输出该年计算机最大可以存贮的阶层数N
要点:
使用log()来计算以2为底的阶层的位数;
sum = log2(1) + log2(2) + log2(3) +.....+ log2(n) = log2(n!);
代码:
#include <stdio.h>#include <cmath> /*int main(){double sum;for (int i = 4, j = 0; j <= 20; i *= 2, j++){int k = 1;sum = 0;while (sum < i){sum += log2(k);k++;}printf("%d\n", k - 2);}}*/int main(){int year;int ans[21] = { 3, 5, 8, 12, 20, 34, 57, 98, 170, 300, 536, 966, 1754,3210, 5910, 10944, 20366, 38064, 71421, 134480, 254016 };while (scanf("%d", &year) && year != 0){getchar();year = (year - 1960) / 10;printf("%d\n", ans[year]);}return 0;}
0 0
- Factstone Benchmark
- Factstone Benchmark
- Factstone Benchmark
- Factstone Benchmark
- Factstone Benchmark
- Factstone Benchmark
- UVa 10916 Factstone Benchmark
- hdu 1141 Factstone Benchmark
- 1119. Factstone Benchmark
- poj2661 Factstone Benchmark
- uva 10916 Factstone Benchmark
- UVA 10916 - Factstone Benchmark
- UVa 10916 - Factstone Benchmark
- uva 10916 - Factstone Benchmark
- uva-10916 - Factstone Benchmark
- POJ 2661 Factstone Benchmark
- Factstone Benchmark hoj 数学题
- 10916 - Factstone Benchmark
- C程序设计语言——导言
- 南邮 OJ 1043 合法序列
- 9.2链表(五)——给定两个用链表表示的整数,每个结点包含一个数位。这些数位是反向存放的,也就是个位排在链表首部
- 降低图片的内存消耗
- 婚姻是爱情的坟墓,却又是爱情最好的归宿
- Factstone Benchmark
- 基于MFC的串口通信
- Android egl和opengl
- UVA 1103
- 开源应用架构之asterisk
- POJ 2513 Colored Sticks(字典树+并查集+欧拉回路)
- hihoCoder 1082 然而沼跃鱼早就看穿了一切
- zoj 2016 poj 1386 Play on Words 欧拉回路+DFS
- Java删除ArrayList中的重复元素的2种方法