22229_Cantor

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

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

Pro.ID

22229

Title

Cantor

Title链接

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

AC

10

Submit

32

Ratio

31.25%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    The ternary expansion of a number is that number written in base 3. A number can have more than one ternary expansion. A ternary expansion is indicated with a subscript 3. For example, 1 = 13 = 0.222...3 , and 0.875 = 0.212121...3 .

    The Cantor set is defined as the real numbers between 0 and 1 inclusive that have a ternary expansion that does not contain a 1. If a number has more than one ternary expansion, it is enough for a single one to not contain a 1.

    For example, 0 = 0.000...3 and 1 = 0.222...3 , so they are in the Cantor set. But 0.875 = 0.212121...3 and this is its only ternary expansion, so it is not in the Cantor set.

    Your task is to determine whether a given number is in the Cantor set.

    输入

    The input consists of several test cases.

    Each test case consists of a single line containing a number x written in decimal notation, with 0 ≤ x ≤ 1, and having at most 6 digits after the decimal point.

    The last line of input is END. This is not a test case.

    输出

    Description

    The ternary expansion of a number is that number written in base 3. A number can have more than one ternary expansion. A ternary expansion is indicated with a subscript 3. For example, 1 = 13 = 0.222...3 , and 0.875 = 0.212121...3 .

    The Cantor set is defined as the real numbers between 0 and 1 inclusive that have a ternary expansion that does not contain a 1. If a number has more than one ternary expansion, it is enough for a single one to not contain a 1.

    For example, 0 = 0.000...3 and 1 = 0.222...3 , so they are in the Cantor set. But 0.875 = 0.212121...3 and this is its only ternary expansion, so it is not in the Cantor set.

    Your task is to determine whether a given number is in the Cantor set.

    Input

    The input consists of several test cases.

    Each test case consists of a single line containing a number x written in decimal notation, with 0 ≤ x ≤ 1, and having at most 6 digits after the decimal point.

    The last line of input is END. This is not a test case.

    Output

    For each test case, output MEMBER if x is in the Cantor set, and NON-MEMBER if x is not in the Cantor set.

    Sample Input

    0
    1
    0.875
    END

    Sample Output

    MEMBER
    MEMBER
    NON-MEMBER

    Source

    样例输入

    0
    1
    0.875
    END

    样例输出

    MEMBER
    MEMBER
    NON-MEMBER

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部