Logo
(追記) (追記ここまで)

21131번 - Brilliant Sequence of Umbrellas 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB113564446.809%

문제

Anton has $n$ umbrellas, each of them has a different number from 1ドル$ to $n$ written on it. He wants to arrange some of the umbrellas in line so that they would form a brilliant sequence of umbrellas (BSU). A sequence of $k$ umbrellas with numbers $a_1, a_2, \ldots, a_k$ is considered a BSU if the following rules apply:

  • $a_i > a_{i-1}$ for all 2ドル \le i \le k$;
  • $\text{gcd}(a_i, a_{i-1}) > \text{gcd}(a_{i-1}, a_{i-2})$ for all 3ドル \le i \le k$. Here, $\text{gcd}(x, y)$ denotes the greatest common divisor of integers $x$ and $y$.

Anton would like to create a long BSU. Making the longest one doesn't bother him, he thinks that a BSU of length at least $\left\lceil\frac{2}{3}\sqrt{n}\right\rceil$ is quite enough.

Anton is busy reading fascinating books about lighthouses, so he asks you to find a BSU that would satisfy him.

입력

The only line contains an integer $n,ドル the number of umbrellas (1ドル \le n \le 10^{12}$).

출력

The first line should contain an integer $k,ドル the length of the BSU you have found ($\left\lceil\frac{2}{3}\sqrt{n}\right\rceil \le k \le 10^6$).

The second line should contain $k$ integers $a_i,ドル the sequence itself (1ドル \le a_i \le n$). The sequence should satisfy the rules mentioned above.

제한

예제 입력 1

10

예제 출력 1

3
1 2 6

예제 입력 2

22

예제 출력 2

4
1 2 6 15

힌트

In the first example, $\left\lceil \frac{2}{3} \cdot \sqrt{10} \right\rceil = 3,ドル $\text{gcd}(1, 2) = 1,ドル $\text{gcd}(2, 6) = 2$.

In the second example, $\left\lceil \frac{2}{3} \cdot \sqrt{22} \right\rceil = 4,ドル $\text{gcd}(1, 2) = 1,ドル $\text{gcd}(2, 6) = 2,ドル $\text{gcd}(6, 15) = 3$.

출처

Camp > Petrozavodsk Programming Camp > Winter 2021 > Day 8: Belarusian SU Contest, Yandex Cup, Grand Prix of Belarud M번

Contest > Open Cup > 2020/2021 Season > Stage 12: Grand Prix of Belarus M번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /