zoukankan      html  css  js  c++  java
  • HDU 1141 Factstone Benchmark (数学 )

    题目链接

    Problem Description

    Amtel has announced that it will release a 128-bit computer chip by 2010, a 256-bit computer by 2020, and so on, continuing its strategy of doubling the word-size every ten years. (Amtel released a 64-bit computer in 2000, a 32-bit computer in 1990, a 16-bit computer in 1980, an 8-bit computer in 1970, and a 4-bit computer, its first, in 1960.) 

    Amtel will use a new benchmark - the Factstone - to advertise the vastly improved capacity of its new chips. The Factstone rating is defined to be the largest integer n such that n! can be represented as an unsigned integer in a computer word.

    Given a year 1960 ≤ y ≤ 2160, what will be the Factstone rating of Amtel's most recently released chip?

    There are several test cases. For each test case, there is one line of input containing y. A line containing 0 follows the last test case. For each test case, output a line giving the Factstone rating.

    Sample Input

    1960
    1981
    0
    

    Sample Output

    3
    8
    

    分析:

    这题目意思很难理解,看了别人的解释后懂了,但是不理解为什么这么做,先留着

    Amtel公司宣布他们会在2010年发行128位元的计算机,

    在2020年发行256位元的计算机,

    在这个策略之下往后每10年就发行2倍位元的计算机。

    (Amtel公司在2000年发行 64位元,1990年发行32位元计算机,

    1980年发行16位元计算机,1970年发行8位元计算机,

    1960年发行4位元计算机,也是第一部计算机)。

    Amtel公司将使用一种新的规格基准 「Factstone」来广告并凸显新一代计算机芯片容量的神速进步。

    「Factstone」的等级被定义为:

    以一个最大的整数 n 表示,使得 n! 可以在一个计算机字组(word,也就是我们说的多少位元)中

    被以 unsigned integer(无号整数)来表示。

    例如:在1960年时的计算机为4位元,也就是一个字组能表达 0~15的整数。

    而 3! 是在这个范围中最大的阶层数了(4! > 15),所以其「Factstone」等级是 3。

    给你一个公元年数 y ,请问最新发行的Amtel计算机其「Factstone」等级是多少?

    代码:

    #include<stdio.h>
    #include<iostream>
    #include<stdlib.h>
    #include<cmath>
    #include<string.h>
    using namespace std;
    int main()
    {
        int n;
        while(~scanf("%d",&n),n)
        {
            int num=(n/10)-194;
            int time=1;
            for(int i=1; i<=num; i++)
                time*=2;///每10年就增长2倍
            double Max=time*log10(2);
            // cout<<Max<<endl;
            double cnt=0,i=1;
            while(cnt<Max)
            {
                cnt+=log10(i);
                i++;
            }
            cout<<i-2<<endl;
        }
        return 0;
    }
  • 相关阅读:
    How to disable ipv6 in ubuntu
    git 暂存区问题
    linux 自动输入密码脚本避免密码确认
    【Linux学习简记 】数据流重定向<,<<,>,>>,2>,2>>
    【Gradle教程】Gradle 基础入门
    vsftpd配置匿名下载,登录上传
    Thunar左侧边栏不完全显示PLACES的解决
    【Jenkins系列教程】流水线通过SSH方式操作Git仓库
    害你加班的bug就是我写的,记一次升级Jenkins插件引发的加班
    Linux 临时终端连接无线网
  • 原文地址:https://www.cnblogs.com/cmmdc/p/6795720.html
Copyright © 2011-2022 走看看