D :: Fractals
Time Limit: 2 Seconds Memory Limit: 65536 KB
Fractals are self-similar patterns. One simple example is to perform the following step on a string of dashes with length 3k to produce similar patterns.
Replace the middle third of each piece of dashes with spaces. Repeat until each piece consists of a single dash.
For instance, if k is 3, we start with a string of 27 dashes:
---------------------------
Remove the middle third of the string:
--------- ---------
and remove the middle third of each piece:
--- --- --- ---
and again:
- - - - - - - -
The process stops when each group of dashes has length 1. You must write a program to specify whether ith character in the output of the last step is “-“ or not.
Input
There are multiple test cases in the input. Each test case is given in a line containing two numbers k (less than 30) and i (at most 3k). The goal is to find whether ith character in the output of the last step of the above process working on a initial string of length 3k is “-“ or not. The input terminates with a line containing 0 0.
Output
For each test case if the ith character in the last output is “-“ you must print “Yes”; otherwise print “No”.
Sample Input
3 6 3 7 0 0
Sample Output
No YesSubmit
Source: 10th Iran Nationwide Internet Contest