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

7913번 - Afternoon Tea 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 32 MB213744230.657%

문제

During his visit at Bytic Islands Byteasar really enjoyed the national beverage of Byteans, that is, tea with milk. This drink is always prepared in a strictly determined manner, which is as follows. Firstly the teacup is filled with tea mixed half and half with milk. Then, an n-letter ceremonial word consisting of letters H and M is chosen. Now, for i = 1, 2, ..., n, the following action is performed: if the i-th letter of the ceremonial word is H, one should drink half of the teacup, add tea until the teacup is full and stir. On the other hand, if the i-th letter of the word is M, one should perform a similar action, however milk should be added instead of tea. After such action is performed for each letter of the ceremonial word, the remaining liquid is disposed of.

Each time Byteasar performs the ceremony, he wonders which of the ingredients he has drunk more: tea or milk. Help Byteasar answer this question.

입력

The first line of input holds an integer n (1 ≤ n ≤ 100 000). The second line contains an n-letter word consisting of letters H and M; this is the ceremonial word used by Byteasar.

출력

Your program should output a single letter H if Byteasar has drunk more tea than milk; a single letter M if he has drunk more milk than tea; or the word HM if he has drunk equal amounts of tea and milk.

제한

예제 입력 1

5
HMHHM

예제 출력 1

H

힌트

Explanation of the example: Byteasar has drunk 1+37/64 teacups of tea and 59/64 teacups of milk in total.

출처

ICPC > Regionals > Europe > Central European Regional Contest > Poland Collegiate Programming Contest > AMPPZ 2011 H번

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

출처

대학교 대회

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

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