mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Kirito
d765b1f1d1
From http://www.acmerblog.com/hdu-1276-%E5%A3%AB%E5%85%B5%E9%98%9F%E5%88%97%E8%AE%AD%E7%BB%83%E9%97%AE%E9%A2%98-1643.html
83 lines
1015 B
C++
83 lines
1015 B
C++
#include<iostream>
|
|
using namespace std;
|
|
int f[5009];
|
|
int main()
|
|
{
|
|
int t;
|
|
int n,i;
|
|
|
|
while(cin>>t)
|
|
{
|
|
while(t--)
|
|
{
|
|
cin>>n;
|
|
for(i=1;i<=n;i++)
|
|
f[i]=i;
|
|
int t;
|
|
if(n<=3)
|
|
{
|
|
printf("1");
|
|
for(i=2;i<=n;i++)
|
|
printf(" %d",i);
|
|
printf("\n");
|
|
continue;
|
|
}
|
|
while(1)
|
|
{
|
|
int leap=0;
|
|
for(i=1;i<=n;i++)
|
|
{
|
|
if(f[i]!=-1)
|
|
{
|
|
leap++;
|
|
}
|
|
if(leap==2)
|
|
{
|
|
leap=0;
|
|
f[i]=-1;
|
|
}
|
|
}
|
|
t=0;
|
|
for(i=1;i<=n;i++)
|
|
if(f[i]!=-1)
|
|
t++;
|
|
|
|
if(t<=3)
|
|
break;
|
|
|
|
leap=0;
|
|
for(i=1;i<=n;i++)
|
|
{
|
|
if(f[i]!=-1)
|
|
leap++;
|
|
if(leap==3)
|
|
{
|
|
f[i]=-1;
|
|
leap=0;
|
|
}
|
|
}
|
|
t=0;
|
|
for(i=1;i<=n;i++)
|
|
if(f[i]!=-1)
|
|
t++;
|
|
if(t<=3)
|
|
break;
|
|
|
|
}
|
|
for(i=1;i<=n;i++)
|
|
if(f[i]!=-1)
|
|
{
|
|
printf("%d",f[i]);
|
|
break;
|
|
}
|
|
i++;
|
|
for(;i<=n;i++)
|
|
if(f[i]!=-1)
|
|
printf(" %d",f[i]);
|
|
printf("\n");
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|