There are 12 sequences listed in FEIS: (1),(1,1),(1,2),(1,3),(2),(2,1),(2,2),(2,3),(3),(3,1),(3,2),(3,3). The (12?2=6)-th lexicographically smallest one among them is (2,1).
需要找出规律
当k为偶数时,输出k/2,k, k...共n项
当k为奇数时,算了,上官方的吧,我也写不出来了...
然后我也编了一组数据,从(1,3,3)倒着带入程序就好理解le
.....(1,1,1) (1,1,2) (1,1,3)(1,2,1)(1,2,2) (1,2,3) (1,3,1) (1,3,2) (1,3,3)
#include<bits/stdc++.h>
using namespace std;
const int m = 1e5;
typedef long long ll;
ll a[3*m+5];
int main()
{
int k,n;
cin>>k>>n;
if(k%2==0)
{
cout<<k/2<<" ";
for(int i = 2; i <= n; i++)
cout<<k<<" ";
}
else
{
for(int i = 1; i <= n; i++)
a[i] = (k+1)/2;
int len = n;
for(int i = 1; i <= n/2; i++) //模拟 ,模拟次数找规律
{
if(a[len] == 1) len--;
else
{
for(int j = len+1; j <= n; j++)
a[j] = k;
a[len]--;
len = n;
}
}
for(int i = 1; i <= len; i++)
cout<<a[i]<<" ";
}
return 0;
}
好吧,终于写完了,hhhhaaa,有错误望指出Ooooooo