本文发表于 301 天前,其中的信息可能已经事过境迁
文章摘要 FakeGPT
加载中...|
P12973 一道搞笑的构造题 题解
题意简述
要求构造一个
解题思路
要想让
我们先把
再考虑使整个序列的字典序最小,我们最终得到的应该是这个:
代码实现
cpp
#include<bits/stdc++.h>
using namespace std;
void work(int x){
if(x==0)return;
if(x==1){cout<<"1 ";return;}
cout<<x-1<<" ";work(x-2);cout<<x<<" ";
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int t,n;
cin>>t;
while(t--){
cin>>n;
work(n);
cout<<'\n';
}
return 0;
}P12973 一道搞笑的构造题 题解https://80yearoldboy.github.io/posts/2025/0913
赞赏博主
