CF1157D.N Problems During K Days

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Polycarp has to solve exactly nn problems to improve his programming skill before an important programming competition. But this competition will be held very soon, most precisely, it will start in kk days. It means that Polycarp has exactly kk days for training!

Polycarp doesn't want to procrastinate, so he wants to solve at least one problem during each of kk days. He also doesn't want to overwork, so if he solves xx problems during some day, he should solve no more than 2x2x problems during the next day. And, at last, he wants to improve his skill, so if he solves xx problems during some day, he should solve at least x+1x+1 problem during the next day.

More formally: let [a1,a2,…,ak][a_1, a_2, \dots, a_k] be the array of numbers of problems solved by Polycarp. The ii-th element of this array is the number of problems Polycarp solves during the ii-th day of his training. Then the following conditions must be satisfied:

  • sum of all aia_i for ii from 11 to kk should be nn;
  • aia_i should be greater than zero for each ii from 11 to kk;
  • the condition ai<ai+1≤2aia_i \lt a_{i + 1} \le 2 a_i should be satisfied for each ii from 11 to k−1k-1.

Your problem is to find any array aa of length kk satisfying the conditions above or say that it is impossible to do it.

Polycarp 需要在一场重要的编程竞赛前恰好解决 nn 道题目,以提升自己的编程能力。而这场竞赛很快就要举行,确切地说,将在 kk 天后开始。这意味着 Polycarp 恰好有 kk 天时间进行训练!

Polycarp 不想拖延,因此他希望在 kk 天中的每一天至少解决一道题。他也不想过度劳累,因此若某天他解决了 xx 道题,则下一天解决的题目数量不能超过 2x2x 道。最后,为了切实提升能力,若某天他解决了 xx 道题,则下一天解决的题目数量至少应为 x+1x+1 道。

更形式化地:设 [a1,a2,…,ak][a_1, a_2, \dots, a_k] 为 Polycarp 每天所解题数构成的数组,其中第 ii 个元素 aia_i 表示他在训练第 ii 天所解决的题目数量。则该数组必须满足以下条件:

  • 所有 aia_i(其中 ii 从 11 到 kk)之和应等于 nn;
  • 对每个 ii(从 11 到 kk),ai>0a_i > 0;
  • 对每个 ii(从 11 到 k−1k-1),需满足条件 ai<ai+1≤2aia_i < a_{i + 1} \le 2 a_i。

你的任务是:找出任意一个长度为 kk 的满足上述条件的数组 aa;若不存在这样的数组,则判定其不可能。

输入格式

The first line of the input contains two integers nn and kk (1≤n≤109,1≤k≤1051 \le n \le 10^9, 1 \le k \le 10^5) — the number of problems Polycarp wants to solve and the number of days Polycarp wants to train.

输入的第一行包含两个整数 nn 和 kk(1≤n≤1091 \le n \le 10^9,1≤k≤1051 \le k \le 10^5)—— 分别表示 Polycarp 想要解决的问题数量以及他想要训练的天数。

输出格式

If it is impossible to find any array aa of length kk satisfying Polycarp's rules of training, print "NO" in the first line.

Otherwise print "YES" in the first line, then print kk integers a1,a2,…,aka_1, a_2, \dots, a_k in the second line, where aia_i should be the number of problems Polycarp should solve during the ii-th day. If there are multiple answers, you can print any.

如果无法找到满足 Polycarp 训练规则的长度为 kk 的数组 aa,则在第一行输出 "NO"。

否则,在第一行输出 "YES",在第二行输出 kk 个整数 a1,a2,…,aka_1, a_2, \dots, a_k,其中 aia_i 表示 Polycarp 在第 ii 天应解决的问题数量。若存在多个答案,输出任意一个即可。

输入输出样例

  • 输入#1

    26 6

    输出#1

    YES
    1 2 4 5 6 8
  • 输入#2

    8 3

    输出#2

    NO
  • 输入#3

    1 1

    输出#3

    YES
    1
  • 输入#4

    9 4

    输出#4

    NO

输入解题思路,AI测评打分。不知道怎么写?

首页