[TopCoder] AB : 문제 해설

in #topcoder6 years ago (edited)

문제 설명

다음 두가지가 주어집니다: NK
Lun이라는 강아지는 다음 조건을 만족하는 문자열에 관심이 있습니다.

  • 문자열에는 정확하게 N개의 문자가 있으며, 각 문자는 'A' 또는 'B' 입니다.
  • 문자열 s는 s[i] = 'A' 와 s[j] = 'B'와같은 K개의 쌍(i,j) (0 <= i < j <= N-1)을 가집니다.

조건을 만족하는 문자열이 있으면 해당 문자열을 찾아서 반환합니다.
그렇지 않으면 빈 문자열을 반환합니다.

정의

Class: AB
Method: createString
Parameters: int, int
Returns: string
Method signature: string createString(int N, int K)
(Method는 반드시 public으로 하세요.)

제한

시간제한(s) : 2.000
메모리제한(MB) : 256

제약조건

  • N은 2와 50 사이입니다.
  • K는 0과 N(N-1)/2 사이입니다.

예시

0)

3
2
Returns: "ABB"
이 문자열을 조건에 맞는 (0,1)과 (0,2)의 두개의 쌍(i,j)을 가집니다.

1)

2
0
Returns: "BA"
K=0 인 정상적인 테스트 케이스를 확인하세요.

2)

5
8
Returns: ""
K의 값에 비해서 5문자는 너무 짧습니다.

3)

10
12
Returns: "BAABBABAAB"
문제를 해결하기 위해 이 예제를 참고하세요.
다른 올바른 예제도 가능합니다.
(역자주: 조건을 만족하는 다른 해도 있다는 뜻입니다.)

Sort:  

@skshin, I gave you an upvote on your first post! Please give me a follow and I will give you a follow in return!

Please also take a moment to read this post regarding bad behavior on Steemit.

Congratulations @skshin! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

Are you a DrugWars early adopter? Benvenuto in famiglia!
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Congratulations @skshin! You received a personal award!

Happy Steem Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

Downvote challenge - Add up to 3 funny badges to your board
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.28
TRX 0.11
JST 0.034
BTC 66274.97
ETH 3175.04
USDT 1.00
SBD 4.06