CF1059C.Sequence Transformation

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Let's call the following process a transformation of a sequence of length nn .

If the sequence is empty, the process ends. Otherwise, append the greatest common divisor (GCD) of all the elements of the sequence to the result and remove one arbitrary element from the sequence. Thus, when the process ends, we have a sequence of nn integers: the greatest common divisors of all the elements in the sequence before each deletion.

You are given an integer sequence 1,2,,n1, 2, \dots, n . Find the lexicographically maximum result of its transformation.

A sequence a1,a2,,ana_1, a_2, \ldots, a_n is lexicographically larger than a sequence b1,b2,,bnb_1, b_2, \ldots, b_n , if there is an index ii such that aj=bja_j = b_j for all j<ij < i , and ai>bia_i > b_i .

输入格式

The first and only line of input contains one integer nn ( 1n1061\le n\le 10^6 ).

输出格式

Output nn integers — the lexicographically maximum result of the transformation.

输入输出样例

  • 输入#1

    3
    

    输出#1

    1 1 3 
  • 输入#2

    2
    

    输出#2

    1 2 
  • 输入#3

    1
    

    输出#3

    1 

说明/提示

In the first sample the answer may be achieved this way:

  • Append GCD (1,2,3)=1(1, 2, 3) = 1 , remove 22 .
  • Append GCD (1,3)=1(1, 3) = 1 , remove 11 .
  • Append GCD (3)=3(3) = 3 , remove 33 .

We get the sequence [1,1,3][1, 1, 3] as the result.

首页