Logo
(追記) (追記ここまで)

19199번 - Borderless Words 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 512 MB811100.000%

문제

A word $w$ is called bordered if there exists a word $u,ドル other then $w$ and empty word $\varepsilon,ドル such that $u$ is both suffix and prefix if $w$. For example, a word <<abbababb>> is bordered because <<abb>> is both its prefix and its suffix. A word that is not bordered is called borderless. For example, a word <<aabab>> is borderless.

Consider all borderless words of length $n$ composed of letters <<a>> and <<b>>. Let us denote the number of such words as $C_n$. Order them lexicographically --- by the first letter, then by the second one, etc, and number from 1 to $C_n$. Given $k$ find the $k$-th word in this order.

입력

The input file contains multiple test cases.

Each test case contains two integers $n$ and $k$ on a line (1ドル \le n \le 64,ドル 1ドル \le k \le C_n$).

Input is followed by a line with $n = k = 0$. There are at most 1000 test cases in one input file.

출력

For each test case output one line --- the $k$-th lexicographically borderless word of length $n$.

제한

예제 입력 1

5 1
5 2
5 3
5 4
5 5
0 0

예제 출력 1

aaaab
aaabb
aabab
aabbb
ababb

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2015 > Day 8: Andrew Stankevich Contest 47 B번

Contest > Open Cup > 2014/2015 Season > Stage 7: Northern Grand Prix B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /