题意:求满足n! < 2^k,n的最大值!

解题:指数比较转换成对数比较,达到降幂!

其中:  log (n!) = log(n)+log(n-1)+...+log(1);

        log(2^k) = k * log(2);

    当然也可以使用斯特林(stirling 公式求解)

公式如下:

        

 程序代码:

 ============================================

 #include<iostream>
#include<cmath>
using namespace std;
int main(){
  int year;
  double res;
  while(cin >> year && year >){
    //add 2 because of the beginning with 4, 1<<2 equals with 4
    int bits = <<((year -)/+);
    double i=;
    res =;
    while(res<bits){
      res += log(i)/log(double());
      i++;
    }
     cout<<i-<<endl;
  }
  return ;
} ============================================

sicily 1119 Factstone Benchmark的更多相关文章

  1. uva 10916 Factstone Benchmark(对数函数的活用)

    Factstone Benchmark Amtel has announced that it will release a 128-bit computer chip by 2010, a 256- ...

  2. HDU 1141 Factstone Benchmark (数学 )

    题目链接 Problem Description Amtel has announced that it will release a 128-bit computer chip by 2010, a ...

  3. Factstone Benchmark

    [问题描述] Amtel已经宣布,到2010年,它将发行128位计算机芯片:到2020年,它将发行256位计算机:等等,Amtel坚持每持续十年将其字大小翻一番的战略.(Amtel于2000年发行了6 ...

  4. poj 2661 Factstone Benchmark (Stirling数)

    //题意是对于给定的x,求满足n! <= 2^(2^x)的最大的n//两边同取以二为底的对数,可得: lg2(n!) <= 2^x 1.   log2(n!) = log2(1) + lo ...

  5. poj 2661 Factstone Benchmark

    /** 大意: 求m!用2进制表示有多少位 m! = 2^n 两边同时取对数 log2(m!) = n 即 log2(1) + log2(2)+log2(3)+log2(4)...+log2(m) = ...

  6. poj2661 Factstone Benchmark(大数不等式同取对数)

    这道题列出不等式后明显是会溢出的大数,但是没有必要写高精度,直接两边取对数(这是很简明实用的处理技巧)得: log2(n!)=log2(n)+log2(n-1)+...+log2(1)<=log ...

  7. Factstone Benchmark(数学)

    http://poj.org/problem?id=2661 题意:Amtel在1960年发行了4位计算机,并实行每十年位数翻一番的策略,将最大整数n作为改变的等级,其中n!表示计算机的无符号整数(n ...

  8. 【poj2661】Factstone Benchmark(斯特林公式)

    传送门 题意: 给出\(x,x\leq 12\),求最大的\(n\),满足\(n!\leq 2^{2^x}\). 思路: 通过斯特林公式: \[ n!\approx \sqrt{2\pi n}\cdo ...

  9. POJ-2661Factstone Benchmark

    Factstone Benchmark Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5577   Accepted: 25 ...

随机推荐

  1. Android ActionBar(转)

    本文内容 关于 ActionBar 必要条件 项目结构 环境 演示一:Action Bar 显示隐藏 演示二:Action Item 显示菜单选项 演示三:Action Home 启用“返回/向上”程 ...

  2. [转]Vim 复制粘帖格式错乱问题的解决办法

    有时候,复制文本(尤其是代码)到 Vim,会出现格式错乱的问题.看样子,应该是自动缩进惹得祸.本文不去深究原因,直接给出解决方法. 1. paste 模式 运行如下命令,进入 paste 模式: :s ...

  3. ajax传值

    $(function(){ $.ajax({ url:'order!seatnum.action', data:{ "entity.id":$("input[name=' ...

  4. 下载文档时Safari浏览器下载后出现".html"问题

    下载代码是需要设置 Response.ContentType = "application/octet-stream", 不要设为application/x-msdownload, ...

  5. 未在本地计算机上注册“Microsoft.Jet.OLEDB.4.0”提供程序(Oledb)

    转载:http://blog.csdn.net/lemontec/article/details/1754413 前几天用c#读 Excel 出现了如下问题未在本地计算机上注册“Microsoft.J ...

  6. PHP magic_quotes_gpc的详细使用方法

    工作中遇到的代码 if (ini_get('magic_quotes_gpc')) { function stripslashesRecursive(array $array){ foreach ($ ...

  7. leetcode修炼之路——387. First Unique Character in a String

    最近公司搬家了,有两天没写了,今天闲下来了,继续开始算法之路. leetcode的题目如下: Given a string, find the first non-repeating characte ...

  8. Objective-C中的内存管理——手动内存管理

    一.引用计数(retainCount) 1.内存的申请 alloc和new是Objective-C语言中申请内存的两种常用方式. 当我们向一个类对象发送一个alloc消息的时候,其会向操作系统在堆中申 ...

  9. A simple stack

    // simple stack.cpp : 定义控制台应用程序的入口点.// #include "stdafx.h"#include<iostream>using na ...

  10. android 9Path图片的使用

    Android UI设计时,经常会使用图片作为背景,比如给按钮设置背景图片时,图片会默认缩放来适应整个按钮.但是有时这种缩放效果并不是我们所需求的.而我们只是希望缩放图片的特定位置,以此来保证按钮的视 ...