Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.
How many such routes are there through a 20×20 grid?
20×20크기의 격자에서 왼쪽 위 시작 점부터 오른쪽 아래 끝 점까지 도달 할 수 있는 경로의 수를 구하기. 목표 지점의 왼쪽까지 갈 수 있는 경로와 위쪽까지 갈 수 있는 경로의 합으로 답을 구할 수 있다. 문제에서는 격자의 크기를 면의 수로 표현하고 있지만 실제 처리는 모서리를 기준으로 하므로 1칸 더 크게 계산한다.
The following iterative sequence is defined for the set of positive integers:
n → n/2 (n is even) n → 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. Although it has not been proved yet (Collatz Problem), it is thought that all starting numbers finish at 1.
Which starting number, under one million, produces the longest chain?
NOTE: Once the chain starts the terms are allowed to go above one million.
어떠한 수 n에 대해 콜라츠 추측을 거치는 횟수는 동일하다. 그리고 수의 범위는 100만. 문제 풀이의 목적은 어디까지나 횟수를 구하는 것이므로 각 수에 대한 콜타츠 추측 횟수를 기록하면 된다. 예를들어 arrNum 배열이 있다고 할 때
The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
Let us list the factors of the first seven triangle numbers:
Find the thirteen adjacent digits in the 1000-digit number that have the greatest product. What is the value of this product?
연속으로 이어지는 1000자리 수에서 연속되는 13개의 정수를 곱했을 때 가장 큰 수를 구하는 문제. 13개의 수를 곱하되 0이 나올 경우에는 그 근처에 있는 수는 결과가 모두 0이 되므로 일정량만큼 건너뛰는게 연산량을 줄이는데 도움이 된다. 범위가 13개일 경우 최대 값은 2조 5천억에 가까우므로 때문에 C++에서는 long long int를 사용했다.