Education codefoces round 102 div2 c

General idea

The monotonically decreasing part of b must be the same as a and the lexicographical order of b is the largest.

#include<bits/stdc++.h>

int main()
{
    
    
	int t;
	scanf("%d",&t);
	while(t--)
	{
    
    
		int n,k;
		scanf("%d%d",&n,&k);
		for(int i=1;i<2*k-n;i++)
		{
    
    
			printf("%d ",i);
		}
		for(int i=k;i>=k*2-n;i--)
		{
    
    
			printf("%d",i);
			if(i==k)
			{
    
    
				printf("\n");
			}
			else
			{
    
    
				printf(" ");
			}
		}
	}
}

Guess you like

Origin blog.csdn.net/p15008340649/article/details/113184932