题解 | #学英语#

学英语

https://www.nowcoder.com/practice/1364723563ab43c99f3d38b5abef83bc

database = {
    0: "zero",
    1: "one",
    2: "two",
    3: "three",
    4: "four",
    5: "five",
    6: "six",
    7: "seven",
    8: "eight",
    9: "nine",
    10: "ten",
    11: "eleven",
    12: "twelve",
    13: "thirteen",
    14: "fourteen",
    15: "fifteen",
    16: "sixteen",
    17: "seventeen",
    18: "eighteen",
    19: "nineteen",
    20: "twenty",
    30: "thirty",
    40: "forty",
    50: "fifty",
    60: "sixty",
    70: "seventy",
    80: "eighty",
    90: "ninety",
    100: "hundred",
    1000: "thousand",
    1000000: "million",
    1000000000: "billion",
    1000000000000: "trillion",
}
input_num = input()
if len(input_num) == 1:
    print(database[int(input_num)])
elif len(input_num) == 2:
    if int(input_num) in database:
        print(database[int(input_num)])
    else:
        shiwei = (int(input_num) // 10) * 10
        gewei = int(input_num) % 10
        print("%s %s" % (database[shiwei], database[gewei]))
elif len(input_num) == 3:
    baiwei = int(input_num) // 100
    baiweiyushu = int(input_num) % 100
    if baiweiyushu == 0:
        print("%s hundred" % (database[baiwei]))
    elif baiweiyushu in database:
        print("%s hundred and %s" % (database[baiwei], database[baiweiyushu]))
    else:
        shiwei = (baiweiyushu // 10) * 10
        gewei = baiweiyushu % 10
        print(
            "%s hundred and %s %s"
            % (database[baiwei], database[shiwei], database[gewei])
        )
elif len(input_num) == 4:
    qianwei = int(input_num) // 1000
    qianweiyushu = int(input_num) % 1000
    if qianweiyushu == 0:
        print("%s thousand" % (database[qianwei]))
    else:
        baiwei = qianweiyushu // 100
        baiweiyushu = qianweiyushu % 100
        if baiwei == 0:
            if baiweiyushu in database:
                print("%s thousand %s" % (database[qianwei], database[baiweiyushu]))
            else:
                shiwei = (baiweiyushu // 10) * 10
                gewei = baiweiyushu % 10
                print(
                    "%s thousand %s %s"
                    % (database[qianwei], database[shiwei], database[gewei])
                )
        else:
            if baiweiyushu == 0:
                print("%s thousand %s hundred" % (database[qianwei], database[baiwei]))
            elif baiweiyushu in database:
                print(
                    "%s thousand %s hundred and %s"
                    % (database[qianwei], database[baiwei], database[baiweiyushu])
                )
            else:
                shiwei = (baiweiyushu // 10) * 10
                gewei = baiweiyushu % 10
                print(
                    "%s thousand %s hundred and %s %s"
                    % (
                        database[qianwei],
                        database[baiwei],
                        database[shiwei],
                        database[gewei],
                    )
                )
elif len(input_num) == 5:
    qianwei = int(input_num) // 1000
    qianweiyushu = int(input_num) % 1000
    if qianwei in database:
        if qianweiyushu == 0:
            print("%s thousand" % (database[qianwei]))
        else:
            baiwei = qianweiyushu // 100
            baiweiyushu = qianweiyushu % 100
            if baiwei == 0:
                if baiweiyushu in database:
                    print("%s thousand %s" % (database[qianwei], database[baiweiyushu]))
                else:
                    shiwei = (baiweiyushu // 10) * 10
                    gewei = baiweiyushu % 10
                    print(
                        "%s thousand %s %s"
                        % (database[qianwei], database[shiwei], database[gewei])
                    )
            else:
                if baiweiyushu == 0:
                    print(
                        "%s thousand %s hundred" % (database[qianwei], database[baiwei])
                    )
                elif baiweiyushu in database:
                    print(
                        "%s thousand %s hundred and %s"
                        % (database[qianwei], database[baiwei], database[baiweiyushu])
                    )
                else:
                    shiwei = (baiweiyushu // 10) * 10
                    gewei = baiweiyushu % 10
                    print(
                        "%s thousand %s hundred and %s %s"
                        % (
                            database[qianwei],
                            database[baiwei],
                            database[shiwei],
                            database[gewei],
                        )
                    )
    else:
        qianweishiwei = (qianwei // 10) * 10
        qianweigewei = qianwei % 10
        if qianweiyushu == 0:
            print("%s %s thousand" % (database[qianweishiwei], database[qianweigewei]))
        else:
            baiwei = qianweiyushu // 100
            baiweiyushu = qianweiyushu % 100
            if baiwei == 0:
                if baiweiyushu in database:
                    print(
                        "%s %s thousand %s"
                        % (
                            database[qianweishiwei],
                            database[qianweigewei],
                            database[baiweiyushu],
                        )
                    )
                else:
                    shiwei = (baiweiyushu // 10) * 10
                    gewei = baiweiyushu % 10
                    print(
                        "%s %s thousand %s %s"
                        % (
                            database[qianweishiwei],
                            database[qianweigewei],
                            database[shiwei],
                            database[gewei],
                        )
                    )
            else:
                if baiweiyushu == 0:
                    print(
                        "%s %s thousand %s hundred"
                        % (
                            database[qianweishiwei],
                            database[qianweigewei],
                            database[baiwei],
                        )
                    )
                elif baiweiyushu in database:
                    print(
                        "%s %s thousand %s hundred and %s"
                        % (
                            database[qianweishiwei],
                            database[qianweigewei],
                            database[baiwei],
                            database[baiweiyushu],
                        )
                    )
                else:
                    shiwei = (baiweiyushu // 10) * 10
                    gewei = baiweiyushu % 10
                    print(
                        "%s %s thousand %s hundred and %s %s"
                        % (
                            database[qianweishiwei],
                            database[qianweigewei],
                            database[baiwei],
                            database[shiwei],
                            database[gewei],
                        )
                    )
elif len(input_num) == 6:
    qianwei = int(input_num) // 1000
    qianweibaiwei = qianwei // 100
    qianweibaiweiyushu = qianwei % 100
    qianweishiwei = (qianweibaiweiyushu // 10) * 10
    qianweigewei = qianweibaiweiyushu % 10
    qianweiyushu = int(input_num) % 1000
    if qianweiyushu == 0:
        if qianweibaiweiyushu == 0:
            print("%s hundred thousand" % (database[qianweibaiwei]))
        elif qianweibaiweiyushu in database:
            print(
                "%s hundred and %s thousand"
                % (database[qianweibaiwei], database[qianweibaiweiyushu])
            )
        else:
            print(
                "%s hundred and %s %s thousand"
                % (
                    database[qianweibaiwei],
                    database[qianweishiwei],
                    database[qianweigewei],
                )
            )
    else:
        baiwei = qianweiyushu // 100
        baiweiyushu = qianweiyushu % 100
        if qianweibaiweiyushu == 0:
            if baiwei == 0:
                if baiweiyushu in database:
                    print(
                        "%s hundred thousand %s"
                        % (database[qianweibaiwei], database[baiweiyushu])
                    )
                else:
                    shiwei = (baiweiyushu // 10) * 10
                    gewei = baiweiyushu % 10
                    print(
                        "%s hundred thousand %s %s"
                        % (database[qianweibaiwei], database[shiwei], database[gewei])
                    )
            else:
                if baiweiyushu == 0:
                    print(
                        "%s hundred thousand %s hundred"
                        % (database[qianweibaiwei], database[baiwei])
                    )
                elif baiweiyushu in database:
                    print(
                        "%s hundred thousand %s hundred and %s"
                        % (
                            database[qianweibaiwei],
                            database[baiwei],
                            database[baiweiyushu],
                        )
                    )
                else:
                    shiwei = (baiweiyushu // 10) * 10
                    gewei = baiweiyushu % 10
                    print(
                        "%s hundred thousand %s hundred and %s %s"
                        % (
                            database[qianweibaiwei],
                            database[baiwei],
                            database[shiwei],
                            database[gewei],
                        )
                    )
        elif qianweibaiweiyushu in database:
            if baiwei == 0:
                if baiweiyushu in database:
                    print(
                        "%s hundred and %s thousand %s"
                        % (
                            database[qianweibaiwei],
                            database[qianweibaiweiyushu],
                            database[baiweiyushu],
                        )
                    )
                else:
                    shiwei = (baiweiyushu // 10) * 10
                    gewei = baiweiyushu % 10
                    print(
                        "%s hundred and %s thousand %s %s"
                        % (
                            database[qianweibaiwei],
                            database[qianweibaiweiyushu],
                            database[shiwei],
                            database[gewei],
                        )
                    )
            else:
                if baiweiyushu == 0:
                    print(
                        "%s hundred and %s thousand %s hundred"
                        % (
                            database[qianweibaiwei],
                            database[qianweibaiweiyushu],
                            database[baiwei],
                        )
                    )
                elif baiweiyushu in database:
                    print(
                        "%s hundred and %s thousand %s hundred and %s"
                        % (
                            database[qianweibaiwei],
                            database[qianweibaiweiyushu],
                            database[baiwei],
                            database[baiweiyushu],
                        )
                    )
                else:
                    shiwei = (baiweiyushu // 10) * 10
                    gewei = baiweiyushu % 10
                    print(
                        "%s hundred and %s thousand %s hundred and %s %s"
                        % (
                            database[qianweibaiwei],
                            database[qianweibaiweiyushu],
                            database[baiwei],
                            database[shiwei],
                            database[gewei],
                        )
                    )
        else:
            if baiwei == 0:
                if baiweiyushu in database:
                    print(
                        "%s hundred and %s %s thousand %s"
                        % (
                            database[qianweibaiwei],
                            database[qianweishiwei],
                            database[qianweigewei],
                            database[baiweiyushu],
                        )
                    )
                else:
                    shiwei = (baiweiyushu // 10) * 10
                    gewei = baiweiyushu % 10
                    print(
                        "%s hundred and %s %s thousand %s %s"
                        % (
                            database[qianweibaiwei],
                            database[qianweishiwei],
                            database[qianweigewei],
                            database[shiwei],
                            database[gewei],
                        )
                    )
            else:
                if baiweiyushu == 0:
                    print(
                        "%s hundred and %s %s thousand %s hundred"
                        % (
                            database[qianweibaiwei],
                            database[qianweishiwei],
                            database[qianweigewei],
                            database[baiwei],
                        )
                    )
                elif baiweiyushu in database:
                    print(
                        "%s hundred and %s %s thousand %s hundred and %s"
                        % (
                            database[qianweibaiwei],
                            database[qianweishiwei],
                            database[qianweigewei],
                            database[baiwei],
                            database[baiweiyushu],
                        )
                    )
                else:
                    shiwei = (baiweiyushu // 10) * 10
                    gewei = baiweiyushu % 10
                    print(
                        "%s hundred and %s %s thousand %s hundred and %s %s"
                        % (
                            database[qianweibaiwei],
                            database[qianweishiwei],
                            database[qianweigewei],
                            database[baiwei],
                            database[shiwei],
                            database[gewei],
                        )
                    )
elif len(input_num) == 7:
    million = int(input_num[0])
    input_num = input_num[1:]
    qianwei = int(input_num) // 1000
    qianweibaiwei = qianwei // 100
    qianweibaiweiyushu = qianwei % 100
    qianweishiwei = (qianweibaiweiyushu // 10) * 10
    qianweigewei = qianweibaiweiyushu % 10
    qianweiyushu = int(input_num) % 1000
    if int(input_num) == 0:
        print("%s million" % (database[million]))
    elif int(input_num[0]) == 0:
        input_num = input_num[1:]
        qianwei = int(input_num) // 1000
        qianweiyushu = int(input_num) % 1000
        if qianwei in database:
            if qianweiyushu == 0:
                print("%s million %s thousand" % (database[million], database[qianwei]))
            else:
                baiwei = qianweiyushu // 100
                baiweiyushu = qianweiyushu % 100
                if baiwei == 0:
                    if baiweiyushu in database:
                        print(
                            "%s million %s thousand %s"
                            % (
                                database[million],
                                database[qianwei],
                                database[baiweiyushu],
                            )
                        )
                    else:
                        shiwei = (baiweiyushu // 10) * 10
                        gewei = baiweiyushu % 10
                        print(
                            "%s million %s thousand %s %s"
                            % (
                                database[million],
                                database[qianwei],
                                database[shiwei],
                                database[gewei],
                            )
                        )
                else:
                    if baiweiyushu == 0:
                        print(
                            "%s million %s thousand %s hundred"
                            % (database[million], database[qianwei], database[baiwei])
                        )
                    elif baiweiyushu in database:
                        print(
                            "%s million %s thousand %s hundred and %s"
                            % (
                                database[million],
                                database[qianwei],
                                database[baiwei],
                                database[baiweiyushu],
                            )
                        )
                    else:
                        shiwei = (baiweiyushu // 10) * 10
                        gewei = baiweiyushu % 10
                        print(
                            "%s million %s thousand %s hundred and %s %s"
                            % (
                                database[million],
                                database[qianwei],
                                database[baiwei],
                                database[shiwei],
                                database[gewei],
                            )
                        )
        else:
            qianweishiwei = (qianwei // 10) * 10
            qianweigewei = qianwei % 10
            if qianweiyushu == 0:
                print(
                    "%s million %s %s thousand"
                    % (
                        database[million],
                        database[qianweishiwei],
                        database[qianweigewei],
                    )
                )
            else:
                baiwei = qianweiyushu // 100
                baiweiyushu = qianweiyushu % 100
                if baiwei == 0:
                    if baiweiyushu in database:
                        print(
                            "%s million %s %s thousand %s"
                            % (
                                database[million],
                                database[qianweishiwei],
                                database[qianweigewei],
                                database[baiweiyushu],
                            )
                        )
                    else:
                        shiwei = (baiweiyushu // 10) * 10
                        gewei = baiweiyushu % 10
                        print(
                            "%s million %s %s thousand %s %s"
                            % (
                                database[million],
                                database[qianweishiwei],
                                database[qianweigewei],
                                database[shiwei],
                                database[gewei],
                            )
                        )
                else:
                    if baiweiyushu == 0:
                        print(
                            "%s million %s %s thousand %s hundred"
                            % (
                                database[million],
                                database[qianweishiwei],
                                database[qianweigewei],
                                database[baiwei],
                            )
                        )
                    elif baiweiyushu in database:
                        print(
                            "%s million %s %s thousand %s hundred and %s"
                            % (
                                database[million],
                                database[qianweishiwei],
                                database[qianweigewei],
                                database[baiwei],
                                database[baiweiyushu],
                            )
                        )
                    else:
                        shiwei = (baiweiyushu // 10) * 10
                        gewei = baiweiyushu % 10
                        print(
                            "%s million %s %s thousand %s hundred and %s %s"
                            % (
                                database[million],
                                database[qianweishiwei],
                                database[qianweigewei],
                                database[baiwei],
                                database[shiwei],
                                database[gewei],
                            )
                        )
    else:
        if qianweiyushu == 0:
            if qianweibaiweiyushu == 0:
                print(
                    "%s million %s hundred thousand"
                    % (database[million], database[qianweibaiwei])
                )
            elif qianweibaiweiyushu in database:
                print(
                    "%s million %s hundred and %s thousand"
                    % (
                        database[million],
                        database[qianweibaiwei],
                        database[qianweibaiweiyushu],
                    )
                )
            else:
                print(
                    "%s million %s hundred and %s %s thousand"
                    % (
                        database[million],
                        database[qianweibaiwei],
                        database[qianweishiwei],
                        database[qianweigewei],
                    )
                )
        else:
            baiwei = qianweiyushu // 100
            baiweiyushu = qianweiyushu % 100
            if qianweibaiweiyushu == 0:
                if baiwei == 0:
                    if baiweiyushu in database:
                        print(
                            "%s million %s hundred thousand %s"
                            % (
                                database[million],
                                database[qianweibaiwei],
                                database[baiweiyushu],
                            )
                        )
                    else:
                        shiwei = (baiweiyushu // 10) * 10
                        gewei = baiweiyushu % 10
                        print(
                            "%s million %s hundred thousand %s %s"
                            % (
                                database[million],
                                database[qianweibaiwei],
                                database[shiwei],
                                database[gewei],
                            )
                        )
                else:
                    if baiweiyushu == 0:
                        print(
                            "%s million %s hundred thousand %s hundred"
                            % (
                                database[million],
                                database[qianweibaiwei],
                                database[baiwei],
                            )
                        )
                    elif baiweiyushu in database:
                        print(
                            "%s million %s hundred thousand %s hundred and %s"
                            % (
                                database[million],
                                database[qianweibaiwei],
                                database[baiwei],
                                database[baiweiyushu],
                            )
                        )
                    else:
                        shiwei = (baiweiyushu // 10) * 10
                        gewei = baiweiyushu % 10
                        print(
                            "%s million %s hundred thousand %s hundred and %s %s"
                            % (
                                database[million],
                                database[qianweibaiwei],
                                database[baiwei],
                                database[shiwei],
                                database[gewei],
                            )
                        )
            elif qianweibaiweiyushu in database:
                if baiwei == 0:
                    if baiweiyushu in database:
                        print(
                            "%s million %s hundred and %s thousand %s"
                            % (
                                database[million],
                                database[qianweibaiwei],
                                database[qianweibaiweiyushu],
                                database[baiweiyushu],
                            )
                        )
                    else:
                        shiwei = (baiweiyushu // 10) * 10
                        gewei = baiweiyushu % 10
                        print(
                            "%s million %s hundred and %s thousand %s %s"
                            % (
                                database[million],
                                database[qianweibaiwei],
                                database[qianweibaiweiyushu],
                                database[shiwei],
                                database[gewei],
                            )
                        )
                else:
                    if baiweiyushu == 0:
                        print(
                            "%s million %s hundred and %s thousand %s hundred"
                            % (
                                database[million],
                                database[qianweibaiwei],
                                database[qianweibaiweiyushu],
                                database[baiwei],
                            )
                        )
                    elif baiweiyushu in database:
                        print(
                            "%s million %s hundred and %s thousand %s hundred and %s"
                            % (
                                database[million],
                                database[qianweibaiwei],
                                database[qianweibaiweiyushu],
                                database[baiwei],
                                database[baiweiyushu],
                            )
                        )
                    else:
                        shiwei = (baiweiyushu // 10) * 10
                        gewei = baiweiyushu % 10
                        print(
                            "%s million %s hundred and %s thousand %s hundred and %s %s"
                            % (
                                database[million],
                                database[qianweibaiwei],
                                database[qianweibaiweiyushu],
                                database[baiwei],
                                database[shiwei],
                                database[gewei],
                            )
                        )
            else:
                if baiwei == 0:
                    if baiweiyushu in database:
                        print(
                            "%s million %s hundred and %s %s thousand %s"
                            % (
                                database[million],
                                database[qianweibaiwei],
                                database[qianweishiwei],
                                database[qianweigewei],
                                database[baiweiyushu],
                            )
                        )
                    else:
                        shiwei = (baiweiyushu // 10) * 10
                        gewei = baiweiyushu % 10
                        print(
                            "%s million %s hundred and %s %s thousand %s %s"
                            % (
                                database[million],
                                database[qianweibaiwei],
                                database[qianweishiwei],
                                database[qianweigewei],
                                database[shiwei],
                                database[gewei],
                            )
                        )
                else:
                    if baiweiyushu == 0:
                        print(
                            "%s million %s hundred and %s %s thousand %s hundred"
                            % (
                                database[million],
                                database[qianweibaiwei],
                                database[qianweishiwei],
                                database[qianweigewei],
                                database[baiwei],
                            )
                        )
                    elif baiweiyushu in database:
                        print(
                            "%s million %s hundred and %s %s thousand %s hundred and %s"
                            % (
                                database[million],
                                database[qianweibaiwei],
                                database[qianweishiwei],
                                database[qianweigewei],
                                database[baiwei],
                                database[baiweiyushu],
                            )
                        )
                    else:
                        shiwei = (baiweiyushu // 10) * 10
                        gewei = baiweiyushu % 10
                        print(
                            "%s million %s hundred and %s %s thousand %s hundred and %s %s"
                            % (
                                database[million],
                                database[qianweibaiwei],
                                database[qianweishiwei],
                                database[qianweigewei],
                                database[baiwei],
                                database[shiwei],
                                database[gewei],
                            )
                        )

全部评论

相关推荐

风的叶脉:不知道但我想要鞭打你( '-' )ノ)`-' ) 加油
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务