题解 | #学英语#
学英语
https://www.nowcoder.com/practice/1364723563ab43c99f3d38b5abef83bc
num = [1,2,3,4,5,6,7,8,9]
word_1 = ['one','two','three','four','five','six','seven','eight','nine']
word_2 = ['twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety']
num_10 = [11,12,13,14,15,16,17,18,19]
word_3 = ['ten','eleven','twelve','thirteen','fourtee','fifteen','sixteen','seventeen','eighteen','nineteen']
def read(three_num:int):
out = []
num_100 = three_num//100
num_1 = three_num%10
num_10= (three_num - num_100*100 - num_1)//10
if num_100:
out.append(word_1[num_100-1])
out.append("hundred")
if num_10:
if num_100:
out.append("and")
if num_10 >=2:
out.append(word_2[num_10-2])
elif num_10 == 1:
out.append(word_3[num_1-10])
if num_1 and num_10!=1:
if num_100 and not num_10:
out.append("and")
out.append(word_1[num_1-1])
return out
s = input()
ls = len(s)
out = []
if ls<=3:
out.extend(read(int(s)))
elif ls<=6:
out.extend(read(int(s[:-3])))
out.append("thousand")
out.extend(read(int(s[-3:])))
elif ls > 6:
out.extend(read(int(s[:-6])))
out.append("million")
out.extend(read(int(s[-6:-3])))
out.append("thousand")
out.extend(read(int(s[-3:])))
print(" ".join(out))

