![]() |
||||||||||
|
||||||||||
Poker ShuffleTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 874 Accepted Submission(s): 285 Problem Description Jason is not only an ACMer, but also a poker nerd. He is able to do a perfect shuffle. In a perfect shuffle, the deck containing K cards, where K is an even number, is split into equal halves of K/2 cards which are then pushed together in a certain way so as to make them perfectly interweave. Suppose the order of the cards is (1, 2, 3, 4, ˇ, K-3, K-2, K-1, K). After a perfect shuffle, the order of the cards will be (1, 3, ˇ, K-3, K-1, 2, 4, ˇ, K-2, K) or (2, 4, ˇ, K-2, K, 1, 3, ˇ, K-3, K-1). Suppose K=2^N and the order of the cards is (1, 2, 3, ˇ, K-2, K-1, K) in the beginning, is it possible that the A-th card is X and the B-th card is Y after several perfect shuffles? Input Input to this problem will begin with a line containing a single integer T indicating the number of datasets. Each case contains five integer, N, A, X, B, Y. 1 <= N <= 1000, 1 <= A, B, X, Y <= 2^N. Output For each input case, output ˇ°Yesˇ± if it is possible that the A-th card is X and the B-th card is Y after several perfect shuffles, otherwise ˇ°Noˇ±. Sample Input
Sample Output
Source | ||||||||||
|