fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;using ll=long long;
  3. int main(){
  4. ios::sync_with_stdio(0);cin.tie(0);
  5. int T;cin>>T;
  6. while(T--){
  7. ll N,K;cin>>N>>K;vector<ll>A(N);
  8. if(N==2)A[0]=K+1,A[1]=A[0]+K;
  9. else{
  10. ll d=1,c=K+1;
  11. for(int i=0;i<N-1&&d<c;i++)d*=2,d=min(d,c);
  12. ll dm=max(1LL,min(d-1,K));
  13. A[0]=1+(K+dm-1)/dm;
  14. ll r=K;
  15. for(int i=0;i<N-1;i++){
  16. ll cap=max(0LL,A[i]-1),t=min(r,cap);
  17. A[i+1]=A[i]+t;r-=t;
  18. }
  19. }
  20. for(int i=0;i<N;i++)cout<<A[i]<<" \n"[i==N-1];
  21. }
  22. }
Success #stdin #stdout 0.01s 5304KB
stdin
2
5 3
2 3
stdout
2 3 5 5 5
4 7