Finite Encyclopedia of Integer Sequences
Posted lwsh123k
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Finite Encyclopedia of Integer Sequences相关的知识,希望对你有一定的参考价值。
题目描述
Let the total number of sequences listed in FEIS be X. Among those sequences, find the (X?2)-th (rounded up to the nearest integer) lexicographically smallest one.
Constraints
1≤N,K≤3×105
N and K are integers.
输入
K N
输出
样例输入
3 2
样例输出
2 1
提示
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
以上是关于Finite Encyclopedia of Integer Sequences的主要内容,如果未能解决你的问题,请参考以下文章
[思维]Finite Encyclopedia of Integer Sequences
AtCoderCODE FESTIVAL 2016 qual C E-順列辞書 / Encyclopedia of Permutations
重磅 | Bplus全新品牌“Blockchain Encyclopedia”下周正式上线!
ISBN|方正|超星|The national academies press|OECD|RSC|Springer Link|Knovel|Encyclopedia Britannica