欧拉计划 发表于 2023-7-31 22:44:44

题目17:统计1~1000的所有英文单词的字母个数

本帖最后由 欧拉计划 于 2023-8-19 03:39 编辑

题目17:统计1~1000的所有英文单词的字符个数

Number letter counts

If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.

If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?

NOTE: Do not count spaces or hyphens. For example, 342 (three hundred and forty-two) contains 23 letters and 115 (one hundred and fifteen) contains 20 letters. The use of "and" when writing out numbers is in compliance with British usage.

题目翻译:

如果用英文写出数字 1 到 5 是:one, two, three, four, five, 那么一共需要 3 + 3 + 5 + 4 + 4 = 19 个字母。

如果数字 1 到 1000(包含 1000)用英文写出,那么一共需要多少个字母呢?

注意:空格和连字符不算在内。例如,342 (three hundred and forty-two) 包含 23 个字母; 115 (one hundred and fifteen) 包含 20 个字母。"and" 的使用与英国标准一致。


视频讲解:

https://www.bilibili.com/video/BV1S84y1o7Ki/


思路解析及源码参考(C & Python):

**** Hidden Message *****

zhangjinxuan 发表于 2023-8-1 20:06:07

我去,数位DP,好难{:10_257:}

我去,好像还不仅仅是数位DP{:10_257:}

鱼C-小师妹 发表于 2023-8-7 14:46:05

{:10_324:}

nkysp 发表于 2023-8-20 15:40:39

Mr.roushan 发表于 2023-9-7 14:22:52

18641

auend 发表于 2023-9-21 02:02:26

这个很适合学生。:)

trikili 发表于 2023-9-21 11:36:59

{:5_90:}

hejiage 发表于 2024-1-4 16:58:05

第十七题了

kalendd 发表于 2024-2-23 08:40:50

{:9_241:}
页: [1]
查看完整版本: 题目17:统计1~1000的所有英文单词的字母个数