• 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;
    }
  • 相关阅读:
    Python面向对象(组合、菱形继承、多态)
    Python面向对象
    Python hash、xml、configparser、sheve、shutil模块讲解 以及 面向对象初识
    python正则re模块
    Python序列化、date、random、os模块
    Python包和日志模块
    python面向对象、模块讲解
    python递归函数、二分法、匿名函数、(sorted、map、filter内置函数应用)
    Python生成器、三元表达式、列表生成式、字典生成式、生成器表达式
    Python迭代器
  • 原文地址:https://www.cnblogs.com/cmmdc/p/6795720.html
Copyright © 2020-2023  润新知