CF BUDDY
← Problems·

1095C · Powers Of Two

1400 · bitmasks, greedy

Problem: A positive integer xx is called a power of two if it can be represented as x=2yx = 2^y, where yy is a non-negative integer. So, the powers of two are 1,2,4,8,16,1, 2, 4, 8, 16, \dots.

You are given two positive integers nn and kk. Your task is to represent nn as the sum of exactly kk powers of two.

Input Format: The only line of the input contains two integers nn and kk (1n1091 \le n \le 10^9, 1k21051 \le k \le 2 \cdot 10^5).

Output Format: If it is impossible to represent nn as the sum of kk powers of two, print NO.

Otherwise, print YES, and then print kk positive integers b1,b2,,bkb_1, b_2, \dots, b_k such that each of bib_i is a power of two, and i=1kbi=n\sum \limits_{i = 1}^{k} b_i = n. If there are multiple answers, you may print any of them.

Sample Cases

Case 1

Input

9 4

Output

YES
1 2 2 4

Case 2

Input

8 1

Output

YES
8

Case 3

Input

5 1

Output

NO

Case 4

Input

3 7

Output

NO

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback