CF1095C.Powers Of Two

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

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.

输入格式

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 ).

输出格式

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.

输入输出样例

  • 输入#1

    9 4
    

    输出#1

    YES
    1 2 2 4 
    
  • 输入#2

    8 1
    

    输出#2

    YES
    8 
    
  • 输入#3

    5 1
    

    输出#3

    NO
    
  • 输入#4

    3 7
    

    输出#4

    NO
    
首页