0과 L을 포함한 N개의 눈금을 가진 자를 만들 때, 임의의 두 눈금 사이 거리가 모두 서로 다르도록 하는 최소 길이의 배치를 구한다.
어려움9백트래킹완전 탐색조합론수학아직 제출이 없습니다시간 제한2초메모리 제한512 MBElly has a very strange measuring ruler. It has length exactly L centimeters and has marks at some (but not necessarily all) positions at integer distances from the beginning. We assume the ruler has marks at its beginning (0) and end (L). The very peculiar thing about this ruler is that all distances between any two (not necessarily neighboring) marks are distinct! More formally, if the ruler has marks at positions 0 = A1 < A2 < ... < AN = L, then (for 1 ≤ i, j, k, p ≤ N and i < j) Aj - Ai = Ak - Ap if and only if j = k and i = p.
Now Elly wants to create such a ruler with N marks, requiring it to be as short as possible. Write a program to help her.
On a single line of the standard input will be given one integer N – the number of marks (including the beginning and end), which the ruler should have.
On a single line of the standard output print N non-negative integers, ordered in increasing order – the positions of the marks of the ruler. The frst position must be 0 and the last must be L, where L is the least possible length, allowing such a ruler with N marks. If more than one solution exists, you can print any of them.