본문 바로가기

project euler6

Problem 17 - Number letter counts (2) 이번에는 기존의 문제를 좀 뒤틀어서 생각해 보겠습니다. 기존 문제는 요약을 하자면 내가 원하는 범위의 숫자에 대해서 알파벳으로 전환하여 그 길이를 모두 더한 결과를 출력하는 문제였습니다. 그렇다면, 기왕해보는 김에 숫자를 입력하면 string으로 출력해주는 프로그램을 만들어 보면 어떨까요?? 이름하여, 숫자에 대한 문자변환기... 가 되는것이죠. 숫자 1 ~ 5에 대해서 문자로 변환하면, 말 그대로 One, Two, Three, Four, Five 로 변환이 되게 됩니다. 그렇다면, 어마어마하게 큰 숫자는 어떻게 변환이 가능할까요?? 예를들어, 104382426112라는 숫자가 있다면... 10조이상에 해당하는 숫자로... 영문자로 변환을 한다면, One Hundred Four Billion Three .. 2020. 12. 10.
Problem 18 - Maximum path sum I By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 3 7 4 2 4 6 8 5 9 3 That is, 3 + 7 + 4 + 9 = 23. Find the maximum total from top to bottom of the triangle below: 75 95 64 17 47 82 18 35 87 10 20 04 82 47 65 19 01 23 75 03 34 88 02 77 73 07 63 67 99 65 04 28 06 16 70 92 41 41 26 56 83 40 80 70 33 41 48 72 33.. 2020. 12. 9.
Problem 17 - Number letter counts (1) 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) con.. 2020. 12. 8.
Problem 16 - Power digit sum 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2^1000? [출처 - projecteuler.net/] 이번에는 문제가 엄청 짧습니다. 문제만 본다면 단순하게 그냥 2에 대해서 거듭제곱을 계속하여 원하는 만큼 수행했을때, 결과값에 대해서 각 자리수에 대한 단순합을 구하는 문제입니다. 하지만 15번 거듭제곱을 수행하면, 누구는 그냥 머리도로 구할 수 있을 것 입니다. 2^10 * 2^5 = 1,024 * 32 = 32,768 이 되겠죠. 그럼 문제와 같이 각 자리수를 더해서 26을 바로 도출해 낼 수 있습니다. 하지만 1,000번이나 거듭제곱을 한다면..... 2020. 12. 7.