《转生王女与天才千金的魔法革命》
cike_bilibili · · 题解
~这部番很好看,推荐大家去看哦。~
我们考虑尽量多挑出几组不互质的数对,考虑对值域每
但这样会导致每一段之间衔接的位置会出问题,但不要紧,我们在
最后
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
namespace Manaka_Ao{
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
char buf[1<<20],*p1=buf,*p2=buf;
inline int read(){
int ans=0,w=1;
char ch=getchar();
while(ch<48||ch>57){
if(ch=='-')w=-1;
ch=getchar();
}
while(ch>=48&&ch<=57){
ans=(ans<<1)+(ans<<3)+ch-48;
ch=getchar();
}
return w*ans;
}
int T;
int n;
signed main(){
T=read();
while(T--){
n=read();
for(int i=1;i+5<=n;i+=6){
if((i/6)&1)cout<<i<<' '<<i+2<<' '<<i+5<<' '<<i+4<<' '<<i+1<<' '<<i+3<<' ';
else cout<<i<<' '<<i+1<<' '<<i+3<<' '<<i+4<<' '<<i+5<<' '<<i+2<<' ';
}
for(int i=n%6-1;i>=0;i--)cout<<n-i<<' ';
cout<<'\n';
}
return 0;
}
}
signed main(){
Manaka_Ao::main();
return 0;
}
/*
构造一个 $n$ 排列,使得连续三个两两互质的位置不超过 6 个
*/