2019. 6. 2. 16:07
728x90

Number letter counts

Problem 17

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~1000을 영어로 작성했을 때의 글자 개수를 구하는 문제. 단, 띄어쓰기, 하이픈( - )은 집계에서 제외한다.

영어의 경우 글자의 구분은 다음과 같이 이루어진다.

1~19 - 각각 고유 명칭이 있으므로 해당 명칭으로 처리.
20~99 - 십의 자리 + 일의 자리. 단, 일의 자리가 0일 경우에는 생략.
100~999은 1~9 + hundred + 1~99

1000은 1 + thousand
...

각 명칭에 해당하는 글자 수를 결과 변수에 더해주면 된다.



728x90

'공부 > 문제풀기' 카테고리의 다른 글

백준 10718 - We love kriii  (0) 2019.07.20
백준 2557 - Hello World  (0) 2019.07.20
프로젝트 오일러 문제 16  (0) 2019.06.02
프로젝트 오일러 문제 15  (0) 2019.06.01
프로젝트 오일러 문제 14  (0) 2019.01.05
Posted by 아야카