题解:CF1957B A BIT of a Construction
lailai0916 · · 题解
题意简述
构造长度为
解题思路
把第
从低到高遍历第
剩下
特别地,当
参考代码
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=200005;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin>>T;
while(T--)
{
int n,k;
cin>>n>>k;
if(n==1)
{
cout<<k<<'\n';
continue;
}
int a1=0;
for(int i=0;i<=30;i++)
{
int x=1<<i;
if(a1+x<=k)a1+=x;
}
cout<<a1<<' '<<k-a1<<' ';
for(int i=3;i<=n;i++)cout<<0<<' ';
cout<<'\n';
}
return 0;
}