题目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 *****
我去,数位DP,好难{:10_257:}
我去,好像还不仅仅是数位DP{:10_257:} {:10_324:} 好 18641 这个很适合学生。:) {:5_90:} 第十七题了 {:9_241:}
页:
[1]