목차

Cutting Brownies

ps
링크acmicpc.net/…
출처BOJ
문제 번호11090
문제명Cutting Brownies
레벨플래티넘 2
분류

게임이론

시간복잡도O(T*(B+D))
인풋사이즈T<=10, B<=500, D<=500
사용한 언어Python 3.13
제출기록32412KB / 36ms
최고기록36ms
해결날짜2026/03/04

풀이

코드

"""Solution code for "BOJ 11090. Cutting Brownies".

- Problem link: https://www.acmicpc.net/problem/11090
- Solution link: http://www.teferi.net/ps/problems/boj/11090

Tags: [game theory]
"""

import sys
from teflib import psutils


@psutils.run_n_times
def main():
    B, D, S = sys.stdin.readline().split()

    h_count, v_count =int(D).bit_length(), int(B).bit_length()
    harry_can_win = h_count > v_count or (h_count == v_count and S == 'Vicky')
    can_win = harry_can_win if S == 'Harry' else not harry_can_win

    print(S, 'can win' if can_win else 'cannot win')


if __name__ == '__main__':
    main()