тјЪ

# CodeForces - 916B№╝ѕТђЮу╗┤+СйЇУ┐љу«Ќ№╝Ѕ

уЅѕТЮЃтБ░Тўј№╝џТюгТќЄСИ║тЇџСИ╗тјЪтѕЏТќЄуФа№╝їТюфу╗ЈтЇџСИ╗тЁЂУ«ИСИЇтЙЌУйгУййсђѓ https://blog.csdn.net/chenquanwei_/article/details/79112338

жЊЙТјЦ№╝џCodeForces - 916B

жбўТёЈ№╝џ

B. Jamie and Binary Sequence (changed after round)
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Jamie is preparing a Codeforces round. He has got an idea for a problem, but does not know how to solve it. Help him write a solution to the following problem:

Find┬аk┬аintegers such that the sum of two to the power of each number equals to the number┬аn┬аand the largest integer in the answer is as small as possible. As there may be multiple answers, you are asked to output the lexicographically largest one.

To be more clear, consider all integer sequence with length┬аk┬а(a1,РђЅa2,РђЅ...,РђЅak)┬аwith┬а . Give a value┬а ┬аto each sequence. Among all sequence(s) that have the minimum┬аy┬аvalue, output the one that is the lexicographically largest.

For definitions of powers and lexicographical order see notes.

Input

The first line consists of two integers┬аn┬аand┬аk┬а(1РђЅРЅцРђЅnРђЅРЅцРђЅ1018,РђЅ1РђЅРЅцРђЅkРђЅРЅцРђЅ105)┬аРђћ the required sum and the length of the sequence.

Output

Output "No" (without quotes) in a single line if there does not exist such sequence. Otherwise, output "Yes" (without quotes) in the first line, and┬аk┬аnumbers separated by space in the second line┬аРђћ the required sequence.

It is guaranteed that the integers in the answer sequence fit the range┬а[РђЅ-РђЅ1018,РђЅ1018].

Examples
input
23 5

output
Yes
3 3 2 1 0

input
13 2

output
No

input
1 2

output
Yes
-1 -1 

жбўУДБ№╝џ

┬атЁѕТ▒ѓтЄ║NуџёС║їУ┐ЏтѕХ№╝їС║їУ┐ЏтѕХуџё1ТЅђтюеуџёСйЇтЇ│ТЅђТ▒ѓт╣ѓТгА№╝їтдѓТъю1уџёСИфТЋ░тцДС║јK№╝їтѕЎУѓ»т«џСИЇУАї№╝ЏтдѓТъют░ЈС║јK№╝їтѕЎУ┐ЏУАїтбътіаТЊЇСйю№╝їтЈ»т░єСИђСИф2^nтЈўТѕљСИцСИф2^(n-1)сђѓТ│еТёЈ№╝џућ▒С║јУдЂТ▒ѓnуџёТюђтцДтђ╝Тюђт░Ј№╝їСИћтГЌтЁИт║ЈТюђтцД№╝їтбътіаСйЇуџёТЌХтђЎС╗јТюђжФўСйЇт╝ђтДІ№╝їТЋ┤СйЊжЎЇСйЇ№╝їтЇ│т░єТЅђТюЅуџёnтЁежЃетЈўТѕљn-1сђѓ

#include <bits/stdc++.h>
using namespace std;

const int maxn = 64;
long long N, K;
int b[maxn*2];

int main()
{
scanf("%I64d%I64d", &N, &K);

for(int i = 0; i < maxn; i++){
K -= (b[maxn + i] = N >> i & 1);
}

if(K < 0) return puts("No") & 0;

for(int i = 2 * maxn - 1; i >= 1; i--){
if(b[i] > K) break;
K -= b[i];
b[i - 1] += b[i] << 1;
b[i] = 0;
}
int k = 0;
while(!b[k]) k++; b[k]--;

puts("Yes");
for(int i = 2 * maxn - 1; i >= k; i--){
while(b[i]--) printf("%d ", i - maxn);
}
for(int i = 1; i <= K; i++){
printf("%d ", k - i - maxn);
}
printf("%d\n", k - K - maxn);

return 0;
}
У┐ўУЃйУЙЊтЁЦ1000СИфтГЌугд