22813_NotOneBitMore

2022-5-16 18:23| 发布者: Hocassian| 查看: 22| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506981487899-Problem List-采集的数据-后羿采集器.html

Pro.ID

22813

Title

Not One Bit More

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22813

AC

1

Submit

9

Ratio

11.11%

时间&空间限制

  • Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Start with an integer, N0, which is greater than 0. Let N1 be the number of ones in the binary representation of N0.  So, if N0 = 27, N1 = 4.

    Ingeneral, let Ni be the number of ones in the binary representation of Ni-1. This sequence will always converge to one.

    Forany starting number, N0 , let K( N0 ) be the minimum i such that Ni is one. For example, if

    N0 = 31, then N1 = 5, N2 = 2, N3 = 1,  so K(31) = 3.

    Givena range of consecutive numbers, and a value X, how many numbers in the range have a K(…) value equal to X?

    输入

    There will be several test cases in the data file. Each test case will consist of three integers on a single line:

    LO  HI  X

    where LO and HI ( 1 ≤ LOHI ≤ 1018 ) are the lower and upper limits of a range of integers, and X ( 0 ≤ X ≤ 10 ) is the target value for K( … ).

    The data file will end with a line with three 0s.

    输出

    Description

    Start with an integer, N0, which is greater than 0. Let N1 be the number of ones in the binary representation of N0.  So, if N0 = 27, N1 = 4.

    Ingeneral, let Ni be the number of ones in the binary representation of Ni-1. This sequence will always converge to one.

    Forany starting number, N0 , let K( N0 ) be the minimum i such that Ni is one. For example, if

    N0 = 31, then N1 = 5, N2 = 2, N3 = 1,  so K(31) = 3.

    Givena range of consecutive numbers, and a value X, how many numbers in the range have a K(…) value equal to X?

    Input

    There will be several test cases in the data file. Each test case will consist of three integers on a single line:

    LO  HI  X

    where LO and HI ( 1 ≤ LOHI ≤ 1018 ) are the lower and upper limits of a range of integers, and X ( 0 ≤ X ≤ 10 ) is the target value for K( … ).

    The data file will end with a line with three 0s.

    Output

    For each test case, output a line with a single integer, representing the number of integers in the range from LO to HI (inclusive) which have a K(…) value equal to X in the input.

    Sample Input

    31 31 3
    31 31 1
    27 31 1      
    27 31 2
    1 4 1      
    1023 1025 1      
    1023 1025 2
    0 0 0

    Sample Output

    1      
    0      
    0      
    3      
    2      
    1      
    1

    Source

    样例输入

    31 31 3
    31 31 1
    27 31 1      
    27 31 2
    1 4 1      
    1023 1025 1      
    1023 1025 2
    0 0 0

    样例输出

    1      
    0      
    0      
    3      
    2      
    1      
    1

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部