蒟蒻只会暴力
代码如下:
#include<bits/stdc++.h>
using namespace std;
int n,r,i,j,k,l,m,o,p,q,s,t,u,v,w,x,y,z,a,b,c,d,ans=0;
int main()
{
cin>>n>>r;
if(r==0)return 0;
else if(r==1)for(i=0;i<n;i++)cout<<" "<<i+1<<endl;
else if(r==2)for(i=0;i<n-1;i++)for(j=0;j<n;j++)cout<<" "<<i+1<<" "<<j+1<<endl;
else if(r==3)for(i=0;i<n-2;i++)for(j=i+1;j<n-1;j++)for(k=j+1;k<n;k++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<endl;
else if(r==4)for(i=0;i<n-3;i++)for(j=i+1;j<n-2;j++)for(k=j+1;k<n-1;k++)for(l=k+1;l<n;l++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<" "<<l+1<<endl;
else if(r==5)for(i=0;i<n-4;i++)for(j=i+1;j<n-3;j++)for(k=j+1;k<n-2;k++)for(l=k+1;l<n-1;l++)for(m=l+1;m<n;m++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<" "<<l+1<<" "<<m+1<<endl;
else if(r==6)for(i=0;i<n-5;i++)for(j=i+1;j<n-4;j++)for(k=j+1;k<n-3;k++)for(l=k+1;l<n-2;l++)for(m=l+1;m<n-1;m++)for(o=m+1;o<n;o++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<" "<<l+1<<" "<<m+1<<" "<<o+1<<endl;
else if(r==7)for(i=0;i<n-6;i++)for(j=i+1;j<n-5;j++)for(k=j+1;k<n-4;k++)for(l=k+1;l<n-3;l++)for(m=l+1;m<n-2;m++)for(o=m+1;o<n-1;o++)for(p=o+1;p<n;p++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<" "<<l+1<<" "<<m+1<<" "<<o+1<<" "<<p+1<<endl;
else if(r==8)for(i=0;i<n-7;i++)for(j=i+1;j<n-6;j++)for(k=j+1;k<n-5;k++)for(l=k+1;l<n-4;l++)for(m=l+1;m<n-3;m++)for(o=m+1;o<n-2;o++)for(p=o+1;p<n-1;p++)for(q=p+1;q<n;q++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<" "<<l+1<<" "<<m+1<<" "<<o+1<<" "<<p+1<<" "<<q+1<<endl;
else if(r==9)for(i=0;i<n-8;i++)for(j=i+1;j<n-7;j++)for(k=j+1;k<n-6;k++)for(l=k+1;l<n-5;l++)for(m=l+1;m<n-4;m++)for(o=m+1;o<n-3;o++)for(p=o+1;p<n-2;p++)for(q=p+1;q<n-1;q++)for(s=q+1;s<n;s++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<" "<<l+1<<" "<<m+1<<" "<<o+1<<" "<<p+1<<" "<<q+1<<" "<<s+1<<endl;
else if(r==10)for(i=0;i<n-9;i++)for(j=i+1;j<n-8;j++)for(k=j+1;k<n-7;k++)for(l=k+1;l<n-6;l++)for(m=l+1;m<n-5;m++)for(o=m+1;o<n-4;o++)for(p=o+1;p<n-3;p++)for(q=p+1;q<n-2;q++)for(s=q+1;s<n-1;s++)for(t=s+1;t<n;t++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<" "<<l+1<<" "<<m+1<<" "<<o+1<<" "<<p+1<<" "<<q+1<<" "<<s+1<<" "<<t+1<<endl;
else if(r==11)for(i=0;i<n-10;i++)for(j=i+1;j<n-9;j++)for(k=j+1;k<n-8;k++)for(l=k+1;l<n-7;l++)for(m=l+1;m<n-6;m++)for(o=m+1;o<n-5;o++)for(p=o+1;p<n-4;p++)for(q=p+1;q<n-3;q++)for(s=q+1;s<n-2;s++)for(t=s+1;t<n-1;t++)for(u=t+1;u<n;u++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<" "<<l+1<<" "<<m+1<<" "<<o+1<<" "<<p+1<<" "<<q+1<<" "<<s+1<<" "<<t+1<<" "<<u+1<<endl;
else if(r==12)for(i=0;i<n-11;i++)for(j=i+1;j<n-10;j++)for(k=j+1;k<n-9;k++)for(l=k+1;l<n-8;l++)for(m=l+1;m<n-7;m++)for(o=m+1;o<n-6;o++)for(p=o+1;p<n-5;p++)for(q=p+1;q<n-4;q++)for(s=q+1;s<n-3;s++)for(t=s+1;t<n-2;t++)for(u=t+1;u<n-1;u++)for(v=u+1;v<n;v++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<" "<<l+1<<" "<<m+1<<" "<<o+1<<" "<<p+1<<" "<<q+1<<" "<<s+1<<" "<<t+1<<" "<<u+1<<" "<<v+1<<endl;
else if(r==13)for(i=0;i<n-12;i++)for(j=i+1;j<n-11;j++)for(k=j+1;k<n-10;k++)for(l=k+1;l<n-9;l++)for(m=l+1;m<n-8;m++)for(o=m+1;o<n-7;o++)for(p=o+1;p<n-6;p++)for(q=p+1;q<n-5;q++)for(s=q+1;s<n-4;s++)for(t=s+1;t<n-3;t++)for(u=t+1;u<n-2;u++)for(v=u+1;v<n-1;v++)for(w=v+1;w<n;w++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<" "<<l+1<<" "<<m+1<<" "<<o+1<<" "<<p+1<<" "<<q+1<<" "<<s+1<<" "<<t+1<<" "<<u+1<<" "<<v+1<<" "<<w+1<<endl;
else if(r==14)for(i=0;i<n-13;i++)for(j=i+1;j<n-12;j++)for(k=j+1;k<n-11;k++)for(l=k+1;l<n-10;l++)for(m=l+1;m<n-9;m++)for(o=m+1;o<n-8;o++)for(p=o+1;p<n-7;p++)for(q=p+1;q<n-6;q++)for(s=q+1;s<n-5;s++)for(t=s+1;t<n-4;t++)for(u=t+1;u<n-3;u++)for(v=u+1;v<n-2;v++)for(w=v+1;w<n-1;w++)for(x=w+1;x<n;x++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<" "<<l+1<<" "<<m+1<<" "<<o+1<<" "<<p+1<<" "<<q+1<<" "<<s+1<<" "<<t+1<<" "<<u+1<<" "<<v+1<<" "<<w+1<<" "<<x+1<<endl;
else if(r==15)for(i=0;i<n-14;i++)for(j=i+1;j<n-13;j++)for(k=j+1;k<n-12;k++)for(l=k+1;l<n-11;l++)for(m=l+1;m<n-10;m++)for(o=m+1;o<n-9;o++)for(p=o+1;p<n-8;p++)for(q=p+1;q<n-7;q++)for(s=q+1;s<n-6;s++)for(t=s+1;t<n-5;t++)for(u=t+1;u<n-4;u++)for(v=u+1;v<n-3;v++)for(w=v+1;w<n-2;w++)for(x=w+1;x<n-1;x++)for(y=x+1;y<n;y++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<" "<<l+1<<" "<<m+1<<" "<<o+1<<" "<<p+1<<" "<<q+1<<" "<<s+1<<" "<<t+1<<" "<<u+1<<" "<<v+1<<" "<<w+1<<" "<<x+1<<" "<<y+1<<endl;
else if(r==16)for(i=0;i<n-15;i++)for(j=i+1;j<n-14;j++)for(k=j+1;k<n-13;k++)for(l=k+1;l<n-12;l++)for(m=l+1;m<n-11;m++)for(o=m+1;o<n-10;o++)for(p=o+1;p<n-9;p++)for(q=p+1;q<n-8;q++)for(s=q+1;s<n-7;s++)for(t=s+1;t<n-6;t++)for(u=t+1;u<n-5;u++)for(v=u+1;v<n-4;v++)for(w=v+1;w<n-3;w++)for(x=w+1;x<n-2;x++)for(y=x+1;y<n-1;y++)for(z=y+1;z<n;z++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<" "<<l+1<<" "<<m+1<<" "<<o+1<<" "<<p+1<<" "<<q+1<<" "<<s+1<<" "<<t+1<<" "<<u+1<<" "<<v+1<<" "<<w+1<<" "<<x+1<<" "<<y+1<<" "<<z+1<<endl;
else if(r==17)for(i=0;i<n-16;i++)for(j=i+1;j<n-15;j++)for(k=j+1;k<n-14;k++)for(l=k+1;l<n-13;l++)for(m=l+1;m<n-12;m++)for(o=m+1;o<n-11;o++)for(p=o+1;p<n-10;p++)for(q=p+1;q<n-9;q++)for(s=q+1;s<n-8;s++)for(t=s+1;t<n-7;t++)for(u=t+1;u<n-6;u++)for(v=u+1;v<n-5;v++)for(w=v+1;w<n-4;w++)for(x=w+1;x<n-3;x++)for(y=x+1;y<n-2;y++)for(z=y+1;z<n-1;z++)for(a=z+1;a<n;a++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<" "<<l+1<<" "<<m+1<<" "<<o+1<<" "<<p+1<<" "<<q+1<<" "<<s+1<<" "<<t+1<<" "<<u+1<<" "<<v+1<<" "<<w+1<<" "<<x+1<<" "<<y+1<<" "<<z+1<<" "<<a+1<<endl;
else if(r==18)for(i=0;i<n-17;i++)for(j=i+1;j<n-16;j++)for(k=j+1;k<n-15;k++)for(l=k+1;l<n-14;l++)for(m=l+1;m<n-13;m++)for(o=m+1;o<n-12;o++)for(p=o+1;p<n-11;p++)for(q=p+1;q<n-10;q++)for(s=q+1;s<n-9;s++)for(t=s+1;t<n-8;t++)for(u=t+1;u<n-7;u++)for(v=u+1;v<n-6;v++)for(w=v+1;w<n-5;w++)for(x=w+1;x<n-4;x++)for(y=x+1;y<n-3;y++)for(z=y+1;z<n-2;z++)for(a=z+1;a<n-1;a++)for(b=a+1;b<n;b++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<" "<<l+1<<" "<<m+1<<" "<<o+1<<" "<<p+1<<" "<<q+1<<" "<<s+1<<" "<<t+1<<" "<<u+1<<" "<<v+1<<" "<<w+1<<" "<<x+1<<" "<<y+1<<" "<<z+1<<" "<<a+1<<" "<<b+1<<endl;
else if(r==19)for(i=0;i<n-18;i++)for(j=i+1;j<n-17;j++)for(k=j+1;k<n-16;k++)for(l=k+1;l<n-15;l++)for(m=l+1;m<n-14;m++)for(o=m+1;o<n-13;o++)for(p=o+1;p<n-12;p++)for(q=p+1;q<n-11;q++)for(s=q+1;s<n-10;s++)for(t=s+1;t<n-9;t++)for(u=t+1;u<n-8;u++)for(v=u+1;v<n-7;v++)for(w=v+1;w<n-6;w++)for(x=w+1;x<n-5;x++)for(y=x+1;y<n-4;y++)for(z=y+1;z<n-3;z++)for(a=z+1;a<n-2;a++)for(b=a+1;b<n-1;b++)for(c=b+1;c<n;c++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<" "<<l+1<<" "<<m+1<<" "<<o+1<<" "<<p+1<<" "<<q+1<<" "<<s+1<<" "<<t+1<<" "<<u+1<<" "<<v+1<<" "<<w+1<<" "<<x+1<<" "<<y+1<<" "<<z+1<<" "<<a+1<<" "<<b+1<<" "<<c+1<<endl;
else if(r==20)for(i=0;i<n-19;i++)for(j=i+1;j<n-18;j++)for(k=j+1;k<n-17;k++)for(l=k+1;l<n-16;l++)for(m=l+1;m<n-15;m++)for(o=m+1;o<n-14;o++)for(p=o+1;p<n-13;p++)for(q=p+1;q<n-12;q++)for(s=q+1;s<n-11;s++)for(t=s+1;t<n-10;t++)for(u=t+1;u<n-9;u++)for(v=u+1;v<n-8;v++)for(w=v+1;w<n-7;w++)for(x=w+1;x<n-6;x++)for(y=x+1;y<n-5;y++)for(z=y+1;z<n-4;z++)for(a=z+1;a<n-3;a++)for(b=a+1;b<n-2;b++)for(c=b+1;c<n-1;c++)for(d=c+1;d<n;d++)cout<<" "<<i+1<<" "<<j+1<<" "<<k+1<<" "<<l+1<<" "<<m+1<<" "<<o+1<<" "<<p+1<<" "<<q+1<<" "<<s+1<<" "<<t+1<<" "<<u+1<<" "<<v+1<<" "<<w+1<<" "<<x+1<<" "<<y+1<<" "<<z+1<<" "<<a+1<<" "<<b+1<<" "<<c+1<<" "<<d+1<<" "<<endl;
return 0;
}