P11895
首先当
当
设此时的
代码:
#include<bits/stdc++.h>
#define int long long
using namespace std;
int T,n,k,choose[200009],ans[200009];
signed main(){
ios::sync_with_stdio(NULL),cin.tie(0),cout.tie(0);
cin>>T;
while(T--){
cin>>n>>k;
int b=(n*(n+1))/2;
if(k>b){
for(int i=1;i<=n;i++) cout<<"0 ";
cout<<"\n";
continue;
}
for(int i=n;i;i--){
if(k>=i){
k-=i;
choose[n-i+1]=1;
}
else choose[n-i+1]=0;
}
int val=1;
for(int i=n;i>=1;i--){
if(choose[i]){
ans[i]=1;
b-=val;
}
else{
ans[i]=0;
}
val++;
}
for(int i=1;i<=n;i++){
if(choose[i]&&!choose[i+1]){
ans[i]+=b;
ans[i+1]-=b;
break;
}
}
for(int i=1;i<=n;i++) cout<<ans[i]<<" ";
cout<<"\n";
}
return 0;
}