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