Secret Lilies and Roses
시간 제한2초메모리 제한2048 MB
숨겨진 이진 문자열에서 특정 위치의 문자를 묻는 질의와 접두 백합 수 곱하기 접미 장미 수를 묻는 질의를 사용해 두 수가 같은 위치를 찾는다.
문제
There are flowers arranged in a line from left to right, which are numbered from to in that order. Each flower is either a lily or a rose. For an integer between and , inclusive, let denote the number of lilies among the leftmost flowers, and let denote the number of roses among the rightmost flowers.
Initially, only the number of flowers is provided to you. The types of the flowers are hidden. You can obtain information on the flowers by making queries. In one query, you can perform one of the following.
Type query: Specify an integer between and , inclusive. You will then receive the type of flower .
Multiply query: Specify an integer between and , inclusive. You will then receive the value of .
Your task is to find an integer between and , inclusive, for which by making a limited number of queries. You can assume that at least one such integer exists for the arrangement of the flower types. Note that you do not need to identify the type of each flower.