Problem:
Score : 800 points

Problem Statement

In Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences of lengths between 1 and N (inclusive) consisting of integers between 1 and K (inclusive) are listed.

Let the total number of sequences listed in FEIS be X. Among those sequences, find the (X/2)-th (rounded up to the nearest integer) lexicographically smallest one.

Constraints

1 \leq N,K \leq 3 × 10^5

N and K are integers.

Input

Input is given from Standard Input in the following format:

K N

Output

Print the (X/2)-th (rounded up to the nearest integer) lexicographically smallest sequence listed in FEIS, with spaces in between, where X is the total number of sequences listed in FEIS.

Sample Input 1

3 2

Sample Output 1

2 1

There are 12 sequences listed in FEIS: (1),(1,1),(1,2),(1,3),(2),(2,1),(2,2),(2,3),(3),(3,1),(3,2),(3,3).
The (12/2 = 6)-th lexicographically smallest one among them is (2,1).

Sample Input 2

2 4

Sample Output 2

1 2 2 2

Sample Input 3

5 14

Sample Output 3

3 3 3 3 3 3 3 3 3 3 3 3 2 2

Solution in C (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <stdio.h>
#include <math.h>
int main(){
unsigned long n,k;
scanf("%lu",&k);
scanf("%lu",&n);
 
if(k % 2 == 0){
printf("%lu",k/2);
for(unsigned long  z = 0; z < n-1; z++){printf(" %lu",k);}
}
 
else{
unsigned long v[n];
v[n-1] = (k+1)/2;
for(unsigned long  a = 0; a < n-1; a++){
v[n-a-2] = (k+1)/2;
if(a % 2 == 0){
unsigned long c = n-1;
while(v[c] == 0){
v[c]= k;
c--;
}
v[c]--;
}
}
for(unsigned long w = 0 ; w < n; w++){if(v[w] != 0){printf("%lu ",v[w]);}}
}
 
printf("\n");
return 0;
}