hdoj 1141 Factstone Benchmark(数学题。。)
来源:互联网 发布:淘宝模特红人有哪些 编辑:程序博客网 时间:2024/05/22 14:32
思路:题目意思是求n!<2^bit时n最大可以取多少;对两边取对数,得到log(1)+log(2)......+log(n)<bit*log(2)
代码如下:
#include <iostream> #include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include <algorithm>#include <vector>using namespace std;int main(){int a[30];int i;int y=1960;int n;long bit;double sum; for(i=0;i<30;i++) { a[i]=y; y+=10;}while(scanf("%d",&n)!=EOF){if(n==0)break;sum=0.0;for(i=0;i<30;i++){if(n>=a[i]&&n<a[i+1]){bit=pow(2,i+2);}}for(i=1;;i++){sum+=log(i)/log(2);if(sum>=(double)bit)break;}printf("%d\n",i-1);} return 0; }
阅读全文
0 0
- hdoj 1141 Factstone Benchmark(数学题。。)
- hdoj-1141-Factstone Benchmark
- HDOJ HDU 1141 Factstone Benchmark
- Factstone Benchmark hoj 数学题
- ACM--数学--HDOJ 1141--Factstone Benchmark--水
- POJ 2661 Factstone Benchmark 数学题
- hdu 1141 Factstone Benchmark
- HDU 1141 Factstone Benchmark
- hdu 1141 Factstone Benchmark
- hdu 1141 Factstone Benchmark
- hdu 1141 Factstone Benchmark
- 杭电1141 Factstone Benchmark
- Factstone Benchmark
- Factstone Benchmark
- Factstone Benchmark
- Factstone Benchmark
- Factstone Benchmark
- Factstone Benchmark
- 安卓 1像素页面保活
- spring中的scope详解
- 谈谈吧,谈谈现在谈谈过去谈谈未来
- redis基础知识
- Python图像处理库PIL中图像格式转换
- hdoj 1141 Factstone Benchmark(数学题。。)
- Django模块模板渲染之django.shortcuts包含的函数及使用
- Xshell5 评估过期,需要采购,不能使用
- windbg 如何在内核模式调试用户空间的程序
- Yii2连接oracle中文乱码解决方法之一
- abstract class和interface的区别
- 如何通过各种数据挖掘运维价值
- 网络流24题一句话题解集合
- mongodb笔记03(MongoDB 条件操作符)