CF1059C.Sequence Transformation
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Let's call the following process a transformation of a sequence of length n .
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 n integers: the greatest common divisors of all the elements in the sequence before each deletion.
You are given an integer sequence 1,2,…,n . Find the lexicographically maximum result of its transformation.
A sequence a1,a2,…,an is lexicographically larger than a sequence b1,b2,…,bn , if there is an index i such that aj=bj for all j<i , and ai>bi .
输入格式
The first and only line of input contains one integer n ( 1≤n≤106 ).
输出格式
Output n 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 , remove 2 .
- Append GCD (1,3)=1 , remove 1 .
- Append GCD (3)=3 , remove 3 .
We get the sequence [1,1,3] as the result.